mirror of
https://github.com/ahgamut/rust-ape-example.git
synced 2024-06-01 02:08:06 +00:00
d976dc883b
via panflute and https://github.com/rust-lang/rust-by-example
22 lines
261 B
Rust
22 lines
261 B
Rust
// ./src/flow_control/loop/return.md
|
|
|
|
|
|
fn part0() {
|
|
let mut counter = 0;
|
|
|
|
let result = loop {
|
|
counter += 1;
|
|
|
|
if counter == 10 {
|
|
break counter * 2;
|
|
}
|
|
};
|
|
|
|
assert_eq!(result, 20);
|
|
}
|
|
|
|
pub fn main() {
|
|
part0();
|
|
}
|
|
|