Skip to content

Commit

Permalink
Drop unsafe code from SeedableRng::seed_from_u64
Browse files Browse the repository at this point in the history
  • Loading branch information
Shnatsel committed Apr 4, 2020
1 parent 2962dea commit 93ee2fd
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions rand_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,7 @@ pub trait SeedableRng: Sized {
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());
}
chunk.copy_from_slice(&x.to_ne_bytes());
}

Self::from_seed(seed)
Expand Down

0 comments on commit 93ee2fd

Please sign in to comment.