Trait Rng
pub trait Rng: TryRng<Error = Infallible>
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 next_u32(&mut self) -> u32Return the next random
u32.fn next_u64(&mut self) -> u64Return the next random
u64.fn fill_bytes(&mut self, dst: &mut [u8])Fill
destwith random data.This method should guarantee that
destis 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).
Implementors
impl<R> Rng for R where R: TryRng<Error = Infallible> + ?Sized,impl<R> Rng for UnwrapErr<R> where R: TryRng<Error = Infallible> + ?Sized,