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() {
let mut counter = 0;
let mut count = 0;
'counting_up: loop {
println!("count = {count}");
let mut remaining = 10;
let result = loop {
counter += 1;
if counter == 10 {
break counter * 2;
loop {
println!("remaining = {remaining}");
if remaining == 9 {
break;
}
if count == 2 {
break 'counting_up;
}
remaining -= 1;
}
};
println!("The result is {result}");
}
count += 1;
}
println!("End count = {count}");
}