Trait Rng
pub trait Rng: TryRng<Error = Infallible> {
// Required methods
fn next_u32(&mut self) -> u32;
fn next_u64(&mut self) -> u64;
fn fill_bytes(&mut self, dst: &mut [u8]);
}Expand description
Trait for infallible random number generators
Rng is a sub-trait of [TryRng] for infallible generators.
§Requirements
See [TryRng#Requirements] which also apply here.
§Usage
The rand crate provides higher level functionality, for example
generation of floating-point values, uniform ranged sampling and shuffling
sequences. In particular, rand::RngExt is an extension trait over Rng
providing many of the methods one might expect to be able to use on an RNG.
§Implementing Rng
Implement [TryRng] with type Error = core::convert::Infallible.
Required Methods§
fn fill_bytes(&mut self, dst: &mut [u8])
fn fill_bytes(&mut self, dst: &mut [u8])
Fill dest with random data.
This method should guarantee that dest is entirely filled
with new data, and may panic if this is impossible
(e.g. reading past the end of a file that is being used as the
source of randomness).