Logo

Programming-Idioms

History of Idiom 69 > diff from v28 to v29

Edit summary for version 29 by freecoder:
[Rust] Bug fixing

Version 28

2018-06-11, 22:50:25

Version 29

2018-12-18, 16:14:06

Idiom #69 Seed random generator

Use seed s to initialize a random generator.

If s is constant, the generator output will be the same each time the program runs. If s is based on the current value of the system clock, the generator output will be different each time.

Idiom #69 Seed random generator

Use seed s to initialize a random generator.

If s is constant, the generator output will be the same each time the program runs. If s is based on the current value of the system clock, the generator output will be different each time.

Imports
extern crate rand;
use rand::{Rng, SeedableRng};
Imports
extern crate rand;
use rand::{Rng, SeedableRng, rngs::StdRng};
Code
let rng = SeedableRng::from_seed(s);
Code
let mut rng = StdRng::from_seed(s);
Doc URL
https://docs.rs/rand/0.5.1/rand/trait.SeedableRng.html
Doc URL
https://docs.rs/rand/*/rand/trait.SeedableRng.html