pub struct Rng { /* private fields */ }Expand description
Implements RomuTrio.
Implementations§
Source§impl Rng
impl Rng
Sourcepub const fn from_seed_with_64bit(seed: u64) -> Self
pub const fn from_seed_with_64bit(seed: u64) -> Self
Creates a new Rng from the given 64-bit seed.
Sourcepub const fn from_seed_with_192bit(seed: [u64; 3]) -> Self
pub const fn from_seed_with_192bit(seed: [u64; 3]) -> Self
Creates a new Rng from the given 192-bit seed.
If the seed is of low quality, user should call Rng::mix() to improve the quality of the
first couple of random numbers.
§Notice
The variables must be seeded such that at least one bit of state is non-zero.
Sourcepub fn seed_source(&self) -> SeedSource
pub fn seed_source(&self) -> SeedSource
Shows which source was used to acquire the seed.
Sourcepub fn seed_with_64bit(&self, seed: u64)
pub fn seed_with_64bit(&self, seed: u64)
Re-seeds the Rng with the given 64-bit seed.
Sourcepub fn seed_with_192bit(&self, seed: [u64; 3])
pub fn seed_with_192bit(&self, seed: [u64; 3])
Re-seeds the Rng from the given 192-bit seed.
If the seed is of low quality, user should call Rng::mix() to improve the quality of the
first couple of random numbers.
§Notice
The variables must be seeded such that at least one bit of state is non-zero.
Sourcepub fn mix(&self)
pub fn mix(&self)
Mixes the state, which should improve the quality of the random numbers.
Should be called when having (re-)seeded the generator with a fixed value of low randomness.
Sourcepub fn fill_bytes(&self, slice: &mut [u8])
pub fn fill_bytes(&self, slice: &mut [u8])
Fills a mutable [u8] slice with random values.
Sourcepub fn mod_u8(&self, n: u8) -> u8
pub fn mod_u8(&self, n: u8) -> u8
Generates a random u8 value in range (0..n).
§Notice
This has a very slight bias. Use Rng::range_u8() instead for no bias.
Sourcepub fn mod_u16(&self, n: u16) -> u16
pub fn mod_u16(&self, n: u16) -> u16
Generates a random u16 value in range (0..n).
§Notice
This has a very slight bias. Use Rng::range_u16() instead for no bias.
Sourcepub fn mod_u32(&self, n: u32) -> u32
pub fn mod_u32(&self, n: u32) -> u32
Generates a random u32 value in range (0..n).
§Notice
This has a very slight bias. Use Rng::range_u32() instead for no bias.
Sourcepub fn mod_u64(&self, n: u64) -> u64
pub fn mod_u64(&self, n: u64) -> u64
Generates a random u64 value in range (0..n).
§Notice
This has a very slight bias. Use Rng::range_u64() instead for no bias.
Sourcepub fn mod_usize(&self, n: usize) -> usize
Available on 64-bit only.
pub fn mod_usize(&self, n: usize) -> usize
Generates a random usize value in range (0..n).
§Notice
This has a very slight bias. Use Rng::range_usize() instead for no bias.
Sourcepub fn range_u8<T: RangeBounds<u8>>(&self, range: T) -> u8
pub fn range_u8<T: RangeBounds<u8>>(&self, range: T) -> u8
Generates a random u8 value in the given range.
Sourcepub fn range_u16<T: RangeBounds<u16>>(&self, range: T) -> u16
pub fn range_u16<T: RangeBounds<u16>>(&self, range: T) -> u16
Generates a random u16 value in the given range.
Sourcepub fn range_u32<T: RangeBounds<u32>>(&self, range: T) -> u32
pub fn range_u32<T: RangeBounds<u32>>(&self, range: T) -> u32
Generates a random u32 value in the given range.
Sourcepub fn range_u64<T: RangeBounds<u64>>(&self, range: T) -> u64
pub fn range_u64<T: RangeBounds<u64>>(&self, range: T) -> u64
Generates a random u64 value in the given range.
Sourcepub fn range_usize<T: RangeBounds<usize>>(&self, range: T) -> usize
pub fn range_usize<T: RangeBounds<usize>>(&self, range: T) -> usize
Generates a random usize value in the given range.
Sourcepub fn range_i8<T: RangeBounds<i8>>(&self, range: T) -> i8
pub fn range_i8<T: RangeBounds<i8>>(&self, range: T) -> i8
Generates a random i8 value in the given range.
Sourcepub fn range_i16<T: RangeBounds<i16>>(&self, range: T) -> i16
pub fn range_i16<T: RangeBounds<i16>>(&self, range: T) -> i16
Generates a random i16 value in the given range.
Sourcepub fn range_i32<T: RangeBounds<i32>>(&self, range: T) -> i32
pub fn range_i32<T: RangeBounds<i32>>(&self, range: T) -> i32
Generates a random i32 value in the given range.
Sourcepub fn range_i64<T: RangeBounds<i64>>(&self, range: T) -> i64
pub fn range_i64<T: RangeBounds<i64>>(&self, range: T) -> i64
Generates a random i64 value in the given range.
Sourcepub fn range_isize<T: RangeBounds<isize>>(&self, range: T) -> isize
pub fn range_isize<T: RangeBounds<isize>>(&self, range: T) -> isize
Generates a random isize value in the given range.