Answers for "rust lang random number in range"

2

rust random number in range

use rand::Rng;

fn main() {
    let mut rng = rand::thread_rng();
    println!("Integer: {}", rng.gen_range(0..10));
    println!("Float: {}", rng.gen_range(0.0..10.0));
}
Posted by: Guest on March-01-2021

Browse Popular Code Answers by Language