Logo

Programming-Idioms

History of Idiom 69 > diff from v29 to v30

Edit summary for version 30 by freecoder:
[Rust] Not needed extern crate in Rust 2018

Version 29

2018-12-18, 16:14:06

Version 30

2018-12-18, 16:14:48

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, rngs::StdRng};
Imports
use rand::{Rng, SeedableRng, rngs::StdRng};
Code
let mut rng = StdRng::from_seed(s);
Code
let mut rng = StdRng::from_seed(s);
Doc URL
https://docs.rs/rand/*/rand/trait.SeedableRng.html
Doc URL
https://docs.rs/rand/*/rand/trait.SeedableRng.html