while
Use while for condition-controlled looping.
Full reference: flow while.
Notes#
- Supported forms + tests: flow while
Syntax#
while condition {
// ...
}
Example#
fn main () -> int {
let mut i: int = 0;
let mut sum: int = 0;
while i < 3 {
sum += i;
i += 1;
}
return sum; // 0 + 1 + 2 = 3
}
See also#
- Full reference: flow while
break/continue: flow break, flow continue
Source repository · Edit this page · View Markdown