From 31e890f49bd5a65271dbb87da81f3fc543253736 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Wed, 16 Oct 2024 17:18:41 +0200 Subject: [PATCH] Create a `while` loop --- loops/src/main.rs | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/loops/src/main.rs b/loops/src/main.rs index dd88564..ca070c7 100644 --- a/loops/src/main.rs +++ b/loops/src/main.rs @@ -1,21 +1,11 @@ fn main() { - let mut count = 0; - 'counting_up: loop { - println!("count = {count}"); - let mut remaining = 10; + let mut number = 3; - loop { - println!("remaining = {remaining}"); - if remaining == 9 { - break; - } - if count == 2 { - break 'counting_up; - } - remaining -= 1; - } + while number != 0 { + println!("{number}!"); - count += 1; + number -= 1; } - println!("End count = {count}"); + + println!("LIFTOFF!!!"); }