Loop loop

This commit is contained in:
Stephan Rehfeld 2026-04-08 17:46:17 +02:00
parent cbc1663ad2
commit c6bba1c4a7

View File

@ -1,9 +1,15 @@
fn main() {
let mut counter = 0;
// While loop is as expected
while counter < 23 {
// Infinite loop in Rust
loop {
println!("In the loop: {}", counter);
counter += 1;
if counter == 23 {
// Break can be used to exit the loop
break;
}
}
println!("Counter is {}", counter);