Numeric rand::distr
Rust rand crate has a distr module for distributions, both trait and impls that simplify random generation, like Alphabetic, Alphanumeric. It also includes a SampleString trait that gives us a sample_string fn on it's impl, for generating a sampling string of len n. So, if we want a random alphanumeric string we can just write: 1use rand::distr::{Alphanumeric, SampleString}; 2 3fn main() { 4 println!("{}", Alphanumeric.sample_string(&mut rand::rng(), 20)); 5} This is incredibly useful, but distr doesn't include a Numeric distribution; which you might say isn't needed, since you can: ...