kw while
Reserved keyword
The list of words: §1.4
Syntax
While = [ Label ":" ] "while" ( Expr | "let" Pattern "=" Expr ) Block ;Grammar: App. A
Defined in
- 5.6 Loops — for accepts Iterable<T> (including iter<T>, collections, ranges); for await accepts Streamable<T>.
- 5.5 Pattern matching — A match MUST be exhaustive.
- 1.4 Keywords — Reserved (cannot be used as names)
Examples
for u in users { … }
for (i, u) in users.enumerate() { … }
for i in 0..n where i % 2 == 0 { … } // filter
for await msg in input { … } // stream<T>
while cond { … }
while let x? = queue.pop() { … }
loop { if done { break result } } // loop is an expression
'outer: for a in xs { for b in ys { if a == b { break 'outer } } }Related diagnostics
break-value, outside-loop, non-exhaustive, pattern-bindings, unreachable-arm