match result.
This commit is contained in:
parent
35796d912b
commit
daec46800b
@ -15,8 +15,13 @@ fn main() {
|
|||||||
io::stdin().read_line(&mut guess_number)
|
io::stdin().read_line(&mut guess_number)
|
||||||
.expect("Failed to read line.");
|
.expect("Failed to read line.");
|
||||||
|
|
||||||
let guess_number: u32 = guess_number.trim().parse()
|
let guess_number: u32 = match guess_number.trim().parse() {
|
||||||
.expect("Not a number.");
|
Ok(num) => num,
|
||||||
|
Err(_) => {
|
||||||
|
println!("Not a number.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
println!("You guess : {:?}", guess_number);
|
println!("You guess : {:?}", guess_number);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user