use rand::Rng;
      
      fn main() {
        let mut rng = rand::thread_rng();
        let n1: u8 = rng.gen();
        let n2: u16 = rng.gen();
        println!("Random u8: {}", n1);
        println!("Random u16: {}", n2);
        println!("Random u32: {}", rng.gen::<u32>());
        println!("Random i32: {}", rng.gen::<i32>());
        println!("Random float: {}", rng.gen::<f64>());
      }
      
      Rust language logo

      Generate random numbers

      0

      0

      avatar
      Giovanny Gongora
      Codiga's Rust Recipes

      numbers with different types

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.