mirror of
https://github.com/ahgamut/rust-ape-example.git
synced 2024-10-31 21:48:49 +00:00
35 lines
504 B
Rust
35 lines
504 B
Rust
|
// ./src/flow_control/loop.md
|
||
|
|
||
|
|
||
|
fn part0() {
|
||
|
let mut count = 0u32;
|
||
|
|
||
|
println!("Let's count until infinity!");
|
||
|
|
||
|
// Infinite loop
|
||
|
loop {
|
||
|
count += 1;
|
||
|
|
||
|
if count == 3 {
|
||
|
println!("three");
|
||
|
|
||
|
// Skip the rest of this iteration
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
println!("{}", count);
|
||
|
|
||
|
if count == 5 {
|
||
|
println!("OK, that's enough");
|
||
|
|
||
|
// Exit this loop
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
pub fn main() {
|
||
|
part0();
|
||
|
}
|
||
|
|