diff --git a/crates/core_simd/src/vector.rs b/crates/core_simd/src/vector.rs index 92984f55e45..a793ae9e391 100644 --- a/crates/core_simd/src/vector.rs +++ b/crates/core_simd/src/vector.rs @@ -263,11 +263,9 @@ where slice.len() >= Self::N, "slice length must be at least the number of elements" ); - assert!(core::mem::size_of::() == Self::N * core::mem::size_of::()); - // Safety: - // - We've checked the length is sufficient. - // - `T` and `Simd` are Copy types. - unsafe { slice.as_ptr().cast::().read_unaligned() } + // SAFETY: We just checked that the slice contains + // at least `N` elements. + unsafe { Self::load(slice.as_ptr().cast()) } } /// Writes a SIMD vector to the first `N` elements of a slice. @@ -293,11 +291,9 @@ where slice.len() >= Self::N, "slice length must be at least the number of elements" ); - assert!(core::mem::size_of::() == Self::N * core::mem::size_of::()); - // Safety: - // - We've checked the length is sufficient - // - `T` and `Simd` are Copy types. - unsafe { slice.as_mut_ptr().cast::().write_unaligned(self) } + // SAFETY: We just checked that the slice contains + // at least `N` elements. + unsafe { self.store(slice.as_mut_ptr().cast()) } } /// Performs elementwise conversion of a SIMD vector's elements to another SIMD-valid type.