Guest User

Untitled

a guest
Jun 25th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. extern crate rand; // In VS Code, this complains about rustc_private. Command line doesn't.
  2.  
  3. use std::io;
  4. use rand::Rng;
  5.  
  6. fn main() {
  7. println!("Guess the number!");
  8.  
  9. let secret_number = rand::thread_rng().gen_range(1, 101);
  10.  
  11. println!("The secret number is: {}", secret_number);
  12.  
  13. println!("Please input your guess.");
  14.  
  15. // This value can be changed.
  16. // Reading lines requires mutable values.
  17. let mut guess = String::new();
  18.  
  19. io::stdin().read_line(&mut guess)
  20. .expect("Failed to read line");
  21.  
  22. println!("You guessed: {}", guess);
  23. }
Add Comment
Please, Sign In to add comment