Trait urandom::rng::Rng

source ·
pub trait Rng {
    fn next_u32(&mut self) -> u32;
    fn next_u64(&mut self) -> u64;
    fn fill_u32(&mut self, buffer: &mut [u32]);
    fn fill_u64(&mut self, buffer: &mut [u64]);
    fn fill_bytes(&mut self, buffer: &mut [u8]);
    fn jump(&mut self);

    fn next_f32(&mut self) -> f32 { ... }
    fn next_f64(&mut self) -> f64 { ... }
}
Expand description

Random number generator interface.

Required Methods

Returns the next u32 in the sequence.

Returns the next u64 in the sequence.

Fills the next u32 elements in the sequence.

Implementations are not required to implement this method with next_u32. This may produce distinct values compared to filling naively with next_u32.

Implementations are required to produce the same result regardless of endianness.

Fills the next u64 elements in the sequence.

Fills the byte slice with uniform random bytes.

Implementations are required to produce the same result regardless of endianness.

Advances the internal state significantly.

Useful to produce deterministic independent random number generators for parallel computation.

Provided Methods

Returns a uniform random f32 in the half-open interval [1.0, 2.0).

As only 23 bits are necessary to construct a random float in this range, implementations may override this method to provide a more efficient implementation.

The default implementation simply gets its random bits from next_u32.

Returns a uniform random f64 in the half-open interval [1.0, 2.0).

As only 52 bits are necessary to construct a random double in this range, implementations may override this method to provide a more efficient implementation.

The default implementation simply gets its random bits from next_u64.

Implementations on Foreign Types

Implementors