Guest User

Untitled

a guest
Oct 22nd, 2019
76
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. use std::io::Write;
  2.  
  3. pub fn get_guess(name: &str) -> u32 {
  4. loop {
  5. println!("{}: Guess a number from 0 to 100", name);
  6. let mut guess = String::new();
  7. std::io::stdout().flush().unwrap();
  8. std::io::stdin().read_line(&mut guess).unwrap();
  9. let guess = guess.trim().parse::<u32>();
  10. if let Ok(s) = guess {
  11. println!("You guessed: {}", s);
  12. break s
  13. }
  14. }
  15. }
RAW Paste Data