Skip to content

Commit 93ee2fd

Browse files
committed
Drop unsafe code from SeedableRng::seed_from_u64
1 parent 2962dea commit 93ee2fd

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

rand_core/src/lib.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -314,11 +314,7 @@ pub trait SeedableRng: Sized {
314314
let xorshifted = (((state >> 18) ^ state) >> 27) as u32;
315315
let rot = (state >> 59) as u32;
316316
let x = xorshifted.rotate_right(rot).to_le();
317-
318-
unsafe {
319-
let p = &x as *const u32 as *const u8;
320-
copy_nonoverlapping(p, chunk.as_mut_ptr(), chunk.len());
321-
}
317+
chunk.copy_from_slice(&x.to_ne_bytes());
322318
}
323319

324320
Self::from_seed(seed)

0 commit comments

Comments
 (0)