rust-random / book

The Rust Rand Book
Other
49 stars 19 forks source link

Update gen_range examples (0.8) #33

Closed ghost closed 3 years ago

ghost commented 3 years ago

Previous version did not work on the playground which seems to use the latest version of rand.

ghost commented 3 years ago

Was it on purpose that you removed the snippet about distributions ?

// Sometimes it's useful to use distributions directly:
let distr = rand::distributions::Uniform::new_inclusive(1, 100);
let mut nums = [0i32; 3];
for x in &mut nums {
    *x = rng.sample(distr);
}

I thought it was not and I put it back in the playground.

dhardy commented 3 years ago

No, it wasn't; not sure how that happened. Your version is still missing the "print nums" line (check "files changed" tab) which is probably worth having.

ghost commented 3 years ago

Sorry about that. Should be fixed now.