diff --git a/rand_core/src/lib.rs b/rand_core/src/lib.rs index 281bedde745..fc341751a11 100644 --- a/rand_core/src/lib.rs +++ b/rand_core/src/lib.rs @@ -41,7 +41,6 @@ use core::convert::AsMut; use core::default::Default; -use core::ptr::copy_nonoverlapping; #[cfg(all(feature = "alloc", not(feature = "std")))] extern crate alloc; #[cfg(all(feature = "alloc", not(feature = "std")))] use alloc::boxed::Box; @@ -313,12 +312,8 @@ pub trait SeedableRng: Sized { // Use PCG output function with to_le to generate x: let xorshifted = (((state >> 18) ^ state) >> 27) as u32; let rot = (state >> 59) as u32; - let x = xorshifted.rotate_right(rot).to_le(); - - unsafe { - let p = &x as *const u32 as *const u8; - copy_nonoverlapping(p, chunk.as_mut_ptr(), chunk.len()); - } + let x = xorshifted.rotate_right(rot); + chunk.copy_from_slice(&x.to_le_bytes()); } Self::from_seed(seed)