Function urandom::seeded

source ·
pub fn seeded(seed: u64) -> Random<impl Rng + Clone>Notable traits for Random<R>impl<R: Rng> Read for Random<R>
Expand description

Creates a new instance of the default pseudorandom number generator with the given seed.

The seed does not need to look random, the PRNG constructor ensures it can handle degenerate seed values.

This function guarantees that the same seed always produces the same sequence of randomness.

Examples

let mut rng = urandom::seeded(42);
let value: i32 = rng.next();
assert_eq!(value, 368317477);