loop structure.
This commit is contained in:
parent
31a6753312
commit
35796d912b
@ -7,6 +7,7 @@ fn main() {
|
|||||||
|
|
||||||
println!("Secret number is {:?}", secret_number);
|
println!("Secret number is {:?}", secret_number);
|
||||||
|
|
||||||
|
loop {
|
||||||
println!("Guessing a number:");
|
println!("Guessing a number:");
|
||||||
|
|
||||||
let mut guess_number = String::new();
|
let mut guess_number = String::new();
|
||||||
@ -22,6 +23,10 @@ fn main() {
|
|||||||
match guess_number.cmp(&secret_number) {
|
match guess_number.cmp(&secret_number) {
|
||||||
Ordering::Less => println!("Too small."),
|
Ordering::Less => println!("Too small."),
|
||||||
Ordering::Greater => println!("Too big."),
|
Ordering::Greater => println!("Too big."),
|
||||||
Ordering::Equal => println!("You win!")
|
Ordering::Equal => {
|
||||||
|
println!("You win!");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user