Create a nested loop
This commit is contained in:
parent
0c0b69835d
commit
99fb3a3f72
1 changed files with 17 additions and 9 deletions
|
@ -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}");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue