about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--crates/core_simd/src/vector.rs16
1 files changed, 6 insertions, 10 deletions
diff --git a/crates/core_simd/src/vector.rs b/crates/core_simd/src/vector.rs
index ff761fc900f..0253f122c98 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>() == Self::N * core::mem::size_of::<T>());
-        // Safety:
-        // - We've checked the length is sufficient.
-        // - `T` and `Simd<T, N>` are Copy types.
-        unsafe { slice.as_ptr().cast::<Self>().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>() == Self::N * core::mem::size_of::<T>());
-        // Safety:
-        // - We've checked the length is sufficient
-        // - `T` and `Simd<T, N>` are Copy types.
-        unsafe { slice.as_mut_ptr().cast::<Self>().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.