Create a loop
with a break
statement
This commit is contained in:
parent
fb1df42282
commit
0c0b69835d
|
@ -1,5 +1,13 @@
|
|||
fn main() {
|
||||
loop {
|
||||
println!("again!");
|
||||
}
|
||||
}
|
||||
let mut counter = 0;
|
||||
|
||||
let result = loop {
|
||||
counter += 1;
|
||||
|
||||
if counter == 10 {
|
||||
break counter * 2;
|
||||
}
|
||||
};
|
||||
|
||||
println!("The result is {result}");
|
||||
}
|
Loading…
Reference in a new issue