Name Description Size
distributions
lib.rs Utilities for random number generation Rand provides utilities to generate random numbers, to convert them to useful types and distributions, and some randomness-related algorithms. # Quick Start To get you started quickly, the easiest and highest-level way to get a random value is to use [`random()`]; alternatively you can use [`thread_rng()`]. The [`Rng`] trait provides a useful API on all RNGs, while the [`distributions`] and [`seq`] modules provide further functionality on top of RNGs. ``` use rand::prelude::*; if rand::random() { // generates a boolean // Try printing a random unicode code point (probably a bad idea)! println!("char: {}", rand::random::<char>()); } let mut rng = rand::thread_rng(); let y: f64 = rng.gen(); // generates a float between 0 and 1 let mut nums: Vec<i32> = (1..100).collect(); nums.shuffle(&mut rng); ``` # The Book For the user guide and further documentation, please read [The Rust Rand Book](https://rust-random.github.io/book). 6644
prelude.rs Convenience re-export of common members Like the standard library's prelude, this module simplifies importing of common items. Unlike the standard prelude, the contents of this module must be imported manually: ``` use rand::prelude::*; # let mut r = StdRng::from_rng(thread_rng()).unwrap(); # let _: f32 = r.gen(); ``` 1284
rng.rs [`Rng`] trait 18954
rngs
seq