1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
use rand::Rng; pub fn rand_num() -> i32 { rand::thread_rng().gen_range(1..=100) } #[cfg(test)] mod tests { use super::*; #[test] fn test_rand_num() { let num = rand_num(); assert!((1..=100).contains(&num)); } }