use rand::distributions::{Distribution, Uniform};
      
      fn main() {
        let mut rng = rand::thread_rng();
        let die = Uniform::from(1..7);
        loop {
          let throw = die.sample(&mut rng);
          println!("Roll the die: {}", throw);
          if throw == 6 {
            break;
          }
        }
      }
      
      Rust language logo

      Random numbers in range

      0

      0

      avatar
      Giovanny Gongora
      Codiga's Rust Recipes

      Get a number in a defined range

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.