]> git.lizzy.rs Git - rust.git/blobdiff - library/core/src/slice/specialize.rs
Replace libstd, libcore, liballoc in docs.
[rust.git] / library / core / src / slice / specialize.rs
index 425cf71626f40edae9d5f8dd2ce577c5e1a07549..80eb590587f993b1e248a65a1c481368c44e994a 100644 (file)
@@ -1,6 +1,3 @@
-use crate::mem::{size_of, transmute_copy};
-use crate::ptr::write_bytes;
-
 pub(super) trait SpecFill<T> {
     fn spec_fill(&mut self, value: T);
 }
@@ -19,17 +16,8 @@ impl<T: Clone> SpecFill<T> for [T] {
 
 impl<T: Copy> SpecFill<T> for [T] {
     fn spec_fill(&mut self, value: T) {
-        if size_of::<T>() == 1 {
-            // SAFETY: The size_of check above ensures that values are 1 byte wide, as required
-            // for the transmute and write_bytes
-            unsafe {
-                let value: u8 = transmute_copy(&value);
-                write_bytes(self.as_mut_ptr(), value, self.len());
-            }
-        } else {
-            for item in self.iter_mut() {
-                *item = value;
-            }
+        for item in self.iter_mut() {
+            *item = value;
         }
     }
 }