Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extern crate rand; // In VS Code, this complains about rustc_private. Command line doesn't.
- use std::io;
- use rand::Rng;
- fn main() {
- println!("Guess the number!");
- let secret_number = rand::thread_rng().gen_range(1, 101);
- println!("The secret number is: {}", secret_number);
- println!("Please input your guess.");
- // This value can be changed.
- // Reading lines requires mutable values.
- let mut guess = String::new();
- io::stdin().read_line(&mut guess)
- .expect("Failed to read line");
- println!("You guessed: {}", guess);
- }
Add Comment
Please, Sign In to add comment