[][src]Trait rand::SeedableRng

pub trait SeedableRng<Seed>: Rng {
    fn reseed(&mut self, _: Seed);
fn from_seed(seed: Seed) -> Self; }

A random number generator that can be explicitly seeded to produce the same stream of randomness multiple times.

Required methods

fn reseed(&mut self, _: Seed)

Reseed an RNG with the given seed.

Example

use rand::{Rng, SeedableRng, StdRng};

let seed: &[_] = &[1, 2, 3, 4];
let mut rng: StdRng = SeedableRng::from_seed(seed);
println!("{}", rng.gen::<f64>());
rng.reseed(&[5, 6, 7, 8]);
println!("{}", rng.gen::<f64>());

fn from_seed(seed: Seed) -> Self

Create a new RNG with the given seed.

Example

use rand::{Rng, SeedableRng, StdRng};

let seed: &[_] = &[1, 2, 3, 4];
let mut rng: StdRng = SeedableRng::from_seed(seed);
println!("{}", rng.gen::<f64>());
Loading content...

Implementors

impl SeedableRng<[u32; 4]> for XorShiftRng[src]

fn reseed(&mut self, seed: [u32; 4])[src]

Reseed an XorShiftRng. This will panic if seed is entirely 0.

fn from_seed(seed: [u32; 4]) -> XorShiftRng[src]

Create a new XorShiftRng. This will panic if seed is entirely 0.

impl<'a> SeedableRng<&'a [u32]> for ChaChaRng[src]

fn from_seed(seed: &'a [u32]) -> ChaChaRng[src]

Create a ChaCha generator from a seed, obtained from a variable-length u32 array. Only up to 8 words are used; if less than 8 words are used, the remaining are set to zero.

impl<'a> SeedableRng<&'a [u32]> for IsaacRng[src]

fn from_seed(seed: &'a [u32]) -> IsaacRng[src]

Create an ISAAC random number generator with a seed. This can be any length, although the maximum number of elements used is 256 and any more will be silently ignored. A generator constructed with a given seed will generate the same sequence of values as all other generators constructed with that seed.

impl<'a> SeedableRng<&'a [u64]> for Isaac64Rng[src]

fn from_seed(seed: &'a [u64]) -> Isaac64Rng[src]

Create an ISAAC random number generator with a seed. This can be any length, although the maximum number of elements used is 256 and any more will be silently ignored. A generator constructed with a given seed will generate the same sequence of values as all other generators constructed with that seed.

impl<'a> SeedableRng<&'a [usize]> for StdRng[src]

impl<S, R: SeedableRng<S>, Rsdr: Reseeder<R> + Default> SeedableRng<(Rsdr, S)> for ReseedingRng<R, Rsdr>[src]

fn from_seed((rsdr, seed): (Rsdr, S)) -> ReseedingRng<R, Rsdr>[src]

Create a new ReseedingRng from the given reseeder and seed. This uses a default value for generation_threshold.

Loading content...