I am new to rust and was following a rust lang book to build a guessing game but I noticed after running the below program doesn't print anything to console when I use print!
but it prints when I use println!
.
Below is the code snippet:
use rand::Rng;
use std::cmp::Ordering;
use std::io;
fn main() {
let number = rand::thread_rng().gen_range(1..=100);
loop {
let mut input = String::from(" ");
io::stdin().read_line(&mut input).expect("failed to read");
let input_number: u32 = input.trim().parse().expect("Not a number");
let message = match number.cmp(&input_number) {
Ordering::Equal => "equal",
Ordering::Less => "less",
Ordering::Greater => "bigg",
};
print!("message: {}", message);
// println!("message: {}", message);
}
}
Can someone help me understand the odd behaviour?