pub struct WyRand { /* private fields */ }Expand description
A Pseudorandom Number generator, powered by the wyrand algorithm. This generator
is based on the final v4.2 reference implementation.
Implementations§
Source§impl WyRand
impl WyRand
Sourcepub const fn new(state: u64) -> WyRand
pub const fn new(state: u64) -> WyRand
Creates a new WyRand instance with the provided seed. Be sure
to obtain the seed value from a good entropy source, either from
hardware, OS source, or from a suitable crate, like getrandom.
Sourcepub const fn gen_u64(seed: u64) -> (u64, u64)
pub const fn gen_u64(seed: u64) -> (u64, u64)
Const WyRand generator. Generates and returns a random u64 value first
and then the advanced state second.
use wyrand::WyRand;
let seed = 123;
let (random_value, new_state) = WyRand::gen_u64(seed);
assert_ne!(random_value, 0);
// The original seed now no longer matches the new state.
assert_ne!(new_state, seed);Trait Implementations§
Source§impl RngCore for WyRand
Available on crate feature rand_core only.
impl RngCore for WyRand
Available on crate feature
rand_core only.Source§fn fill_bytes(&mut self, dest: &mut [u8])
fn fill_bytes(&mut self, dest: &mut [u8])
Fill
dest with random data. Read moreSource§impl SeedableRng for WyRand
Available on crate feature rand_core only.
impl SeedableRng for WyRand
Available on crate feature
rand_core only.Source§type Seed = [u8; 8]
type Seed = [u8; 8]
Seed type, which is restricted to types mutably-dereferenceable as
u8
arrays (we recommend [u8; N] for some N). Read moreSource§fn from_seed(seed: <WyRand as SeedableRng>::Seed) -> WyRand
fn from_seed(seed: <WyRand as SeedableRng>::Seed) -> WyRand
Create a new PRNG using the given seed. Read more
Source§fn seed_from_u64(state: u64) -> Self
fn seed_from_u64(state: u64) -> Self
Create a new PRNG using a
u64 seed. Read moreimpl Eq for WyRand
impl StructuralPartialEq for WyRand
Auto Trait Implementations§
impl Freeze for WyRand
impl RefUnwindSafe for WyRand
impl Send for WyRand
impl Sync for WyRand
impl Unpin for WyRand
impl UnwindSafe for WyRand
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