Skip to main content

Rng

Trait Rng 

Source
pub trait Rng {
    // Required method
    fn fill_bytes(&mut self, bytes: &mut [u8]);
}
🔬This is a nightly-only experimental API. (random #130703)
Expand description

A source of randomness.

Required Methods§

Source

fn fill_bytes(&mut self, bytes: &mut [u8])

🔬This is a nightly-only experimental API. (random #130703)

Fills bytes with random bytes.

Note that calling fill_bytes multiple times is not equivalent to calling fill_bytes once with a larger buffer. An Rng is allowed to return different bytes for those two cases. For instance, this allows an Rng to generate a word at a time and throw part of it away if not needed.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl Rng for SystemRng

Source§

impl<'a, R> Rng for &'a mut R
where R: Rng + ?Sized,

Implements Rng for mutable references to random number generators by forwarding all methods to the referenced generator.