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.
fn reseed(&mut self, _: Seed)
Reseed an RNG with the given seed.
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.
use rand::{Rng, SeedableRng, StdRng};
let seed: &[_] = &[1, 2, 3, 4];
let mut rng: StdRng = SeedableRng::from_seed(seed);
println!("{}", rng.gen::<f64>());
Reseed an XorShiftRng. This will panic if seed
is entirely 0.
Create a new XorShiftRng. This will panic if seed
is entirely 0.
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.
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.
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.
Create a new ReseedingRng
from the given reseeder and
seed. This uses a default value for generation_threshold
.