Function random
fn random<T>() -> T
where
crate::distr::StandardUniform: Distribution<T>
Generate a random value using the thread-local random number generator.
This function is shorthand for [rng()].random():
- See
ThreadRngfor documentation of the generator and security - See
StandardUniformfor documentation of supported types and distributions
Examples
let x = ;
println!;
let y = ;
println!;
if random
If you're calling random() repeatedly, consider using a local rng
handle to save an initialization-check on each usage:
use Rng; // provides the `random` method
let mut rng = rng; // a local handle to the generator
let mut v = vec!;
for x in v.iter_mut