Random (rng)
202307032234
Status: #idea
Tags: Rust
Random (rng)
use rand::Rng; // Rng trait defines methods implemented by RNGs
let secret_number = rand::thread_rng().gen_range(1..=100); // Range of [1, 100]
rand::thread_rnggives us an RNG that is local to the current thread of execution and is seeded by the OS
Info
1..=100 is a range expression, which has inclusive lower and upper bounds.