pub struct XorShift128Plus(/* private fields */);
Expand description
§Examples
Construct a RNG from an integer.
extern crate xorshift128plus;
use xorshift128plus::XorShift128Plus;
let mut rng = XorShift128Plus::from_u32(4293262078);
println!("First random float: {}", rng.next());
println!("Second random float: {}", rng.next());
You can also construct a RNG by supplying 16 bytes of raw data. Here we are using the rand
crates rand::random
to generate 16 bytes
of random data to use as the initial seed. This data could also come from a file, a database or
anywhere else really.
extern crate rand;
extern crate xorshift128plus;
use xorshift128plus::XorShift128Plus;
let seed: [u8; 16] = rand::random();
let mut rng = XorShift128Plus::from_bytes(seed);
println!("First random float: {}", rng.next());
println!("Second random float: {}", rng.next());
Implementations§
Source§impl XorShift128Plus
impl XorShift128Plus
Sourcepub fn from_bytes(seed: [u8; 16]) -> XorShift128Plus
pub fn from_bytes(seed: [u8; 16]) -> XorShift128Plus
Constructs a new RNG with the seed specified as 16 bytes of raw data.
Sourcepub fn from_u32(seed: u32) -> XorShift128Plus
pub fn from_u32(seed: u32) -> XorShift128Plus
Constructs a new RNG with the seed specified as a unsigned 32bit integer. Note that this seeding is suboptimal since it will only contain 32 bits of entropy instead of 128 bits.
Sourcepub fn from_u64(seed: u64) -> XorShift128Plus
pub fn from_u64(seed: u64) -> XorShift128Plus
Constructs a new RNG with the seed specified as a unsigned 64bit integer. Note that this seeding is suboptimal since it will only contain 64 bits of entropy instead of 128 bits.
Auto Trait Implementations§
impl Freeze for XorShift128Plus
impl RefUnwindSafe for XorShift128Plus
impl Send for XorShift128Plus
impl Sync for XorShift128Plus
impl Unpin for XorShift128Plus
impl UnwindSafe for XorShift128Plus
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more