Skip to content

Commit

Permalink
Merge pull request #772 from steffahn/master
Browse files Browse the repository at this point in the history
Add information about || and && to grammar describing `while let`.
  • Loading branch information
Centril committed Apr 8, 2020
2 parents 05189cf + 532060a commit e8f420d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/expressions/loop-expr.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ have type compatible with the value of the `break` expression(s).

> **<sup>Syntax</sup>**\
> _PredicateLoopExpression_ :\
> &nbsp;&nbsp; `while` [_Expression_]<sub>except struct expression</sub> [_BlockExpression_]
> &nbsp;&nbsp; `while` [_Expression_]<sub>_except struct expression_</sub> [_BlockExpression_]
A `while` loop begins by evaluating the boolean loop conditional expression. If
the loop conditional expression evaluates to `true`, the loop body block
Expand All @@ -67,7 +67,7 @@ while i < 10 {

> **<sup>Syntax</sup>**\
> [_PredicatePatternLoopExpression_] :\
> &nbsp;&nbsp; `while` `let` [_MatchArmPatterns_] `=` [_Expression_]<sub>except struct expression</sub>
> &nbsp;&nbsp; `while` `let` [_MatchArmPatterns_] `=` [_Expression_]<sub>_except struct or lazy boolean operator expression_</sub>
> [_BlockExpression_]
A `while let` loop is semantically similar to a `while` loop but in place of a
Expand Down Expand Up @@ -123,11 +123,13 @@ while let Some(v @ 1) | Some(v @ 2) = vals.pop() {
}
```

As is the case in [`if let` expressions], the scrutinee cannot be a [lazy boolean operator expression][_LazyBooleanOperatorExpression_].

## Iterator loops

> **<sup>Syntax</sup>**\
> _IteratorLoopExpression_ :\
> &nbsp;&nbsp; `for` [_Pattern_] `in` [_Expression_]<sub>except struct expression</sub>
> &nbsp;&nbsp; `for` [_Pattern_] `in` [_Expression_]<sub>_except struct expression_</sub>
> [_BlockExpression_]
A `for` expression is a syntactic construct for looping over elements provided
Expand Down Expand Up @@ -294,3 +296,5 @@ expression `()`.
[`match` expression]: match-expr.md
[scrutinee]: ../glossary.md#scrutinee
[temporary values]: ../expressions.md#temporary-lifetimes
[_LazyBooleanOperatorExpression_]: operator-expr.md#lazy-boolean-operators
[`if let` expressions]: if-expr.md#if-let-expressions

0 comments on commit e8f420d

Please sign in to comment.