Trait sgx_rand::SeedableRng
source · [−]pub trait SeedableRng<Seed>: Rng {
fn reseed(&mut self, seed: Seed);
fn from_seed(seed: Seed) -> Self;
}
Expand description
A random number generator that can be explicitly seeded to produce the same stream of randomness multiple times.
Required Methods
sourcefn reseed(&mut self, seed: Seed)
fn reseed(&mut self, seed: Seed)
Reseed an RNG with the given seed.
Example
use sgx_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>());