Create a nested loop

This commit is contained in:
Manuel Thalmann 2024-10-16 17:18:24 +02:00
parent 0c0b69835d
commit 99fb3a3f72

View file

@ -1,13 +1,21 @@
fn main() { fn main() {
let mut counter = 0; let mut count = 0;
'counting_up: loop {
println!("count = {count}");
let mut remaining = 10;
let result = loop { loop {
counter += 1; println!("remaining = {remaining}");
if remaining == 9 {
if counter == 10 { break;
break counter * 2;
} }
}; if count == 2 {
break 'counting_up;
println!("The result is {result}"); }
remaining -= 1;
}
count += 1;
}
println!("End count = {count}");
} }