From f7cbc03210726b6d6b29e5b1ca26b9d5afff0fb7 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Sat, 12 Oct 2024 00:22:11 +0200 Subject: [PATCH] Exit game after correct guess --- guessing_game/src/main.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/guessing_game/src/main.rs b/guessing_game/src/main.rs index c5601cb..a58990e 100644 --- a/guessing_game/src/main.rs +++ b/guessing_game/src/main.rs @@ -22,7 +22,10 @@ fn main() { match guess.cmp(&secret_number) { Ordering::Less => println!("Too small!"), Ordering::Greater => println!("Too big!"), - Ordering::Equal => println!("You win!"), + Ordering::Equal => { + println!("You win!"); + break; + }, } } }