match result.

This commit is contained in:
licsber 2024-08-21 17:10:16 +08:00
parent 35796d912b
commit daec46800b

View File

@ -15,8 +15,13 @@ fn main() {
io::stdin().read_line(&mut guess_number)
.expect("Failed to read line.");
let guess_number: u32 = guess_number.trim().parse()
.expect("Not a number.");
let guess_number: u32 = match guess_number.trim().parse() {
Ok(num) => num,
Err(_) => {
println!("Not a number.");
continue;
}
};
println!("You guess : {:?}", guess_number);