diff --git a/src/main.rs b/src/main.rs index a42041d..0add9b8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,17 +1,19 @@ -use std::io; +use std::io::{self, Write}; use rand::Rng; use std::cmp::Ordering; +// use std::str; fn main() { println!("Let's play the guessing game!"); let secret_number = rand::thread_rng().gen_range(1..=100); loop { - println!(" What's your guess?"); + print!("What's your guess? "); + io::stdout().flush().unwrap(); let mut guess = String::new(); io::stdin() .read_line(&mut guess) .expect("Sorry; something didn't quite work."); - let guess: u32 = match guess.trim().parse() { + let guess: u32 = match guess.trim_end().parse() { Ok(num) => num, Err(_) => continue, }; @@ -23,5 +25,6 @@ fn main() { break; } } + // io::stdout().flush().unwrap(); } }