Skip to content

Commit ac4ff0f

Browse files
committed
Consolidate scrutinee expression grammar into match-expr.md, with links in if-expr and loop-expr
1 parent 0e7115d commit ac4ff0f

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

src/expressions/if-expr.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,12 @@ assert_eq!(y, "Bigger");
4141

4242
> **<sup>Syntax</sup>**\
4343
> _IfLetExpression_ :\
44-
> &nbsp;&nbsp; `if` `let` [_Pattern_] `=` _Scrutinee_
44+
> &nbsp;&nbsp; `if` `let` [_Pattern_] `=` [_Scrutinee_]<sub>_except lazy boolean operator expression_</sub>
4545
> [_BlockExpression_]\
4646
> &nbsp;&nbsp; (`else` (
4747
> [_BlockExpression_]
4848
> | _IfExpression_
4949
> | _IfLetExpression_ ) )<sup>\?</sup>
50-
>
51-
> _Scrutinee_:\
52-
> &nbsp;&nbsp; [_Expression_]<sub>_except struct or lazy boolean operator expression_</sub>
5350
5451
An `if let` expression is semantically similar to an `if` expression but in place of a condition operand it expects the keyword `let` followed by a pattern, an `=` and a [scrutinee] operand.
5552
If the value of the scrutinee matches the pattern, the corresponding block will execute.
@@ -151,6 +148,7 @@ if let PAT = ( EXPR || EXPR ) { .. }
151148
[_Expression_]: ../expressions.md
152149
[_LazyBooleanOperatorExpression_]: operator-expr.md#lazy-boolean-operators
153150
[_Pattern_]: ../patterns.md
151+
[_Scrutinee_]: match-expr.md
154152
[_eRFCIfLetChain_]: https://github.com/rust-lang/rfcs/blob/master/text/2497-if-let-chains.md#rollout-plan-and-transitioning-to-rust-2018
155153
[`match` expression]: match-expr.md
156154
[boolean type]: ../types/boolean.md

src/expressions/loop-expr.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,8 @@ while i < 10 {
6262

6363
> **<sup>Syntax</sup>**\
6464
> [_PredicatePatternLoopExpression_] :\
65-
> &nbsp;&nbsp; `while` `let` [_Pattern_] `=` _Scrutinee_
65+
> &nbsp;&nbsp; `while` `let` [_Pattern_] `=` [_Scrutinee_]<sub>_except lazy boolean operator expression_</sub>
6666
> [_BlockExpression_]
67-
>
68-
> _Scrutinee_:\
69-
> &nbsp;&nbsp; [_Expression_]<sub>_except struct or lazy boolean operator expression_</sub>
7067
7168

7269
A `while let` loop is semantically similar to a `while` loop but in place of a condition expression it expects the keyword `let` followed by a pattern, an `=`, a [scrutinee] expression and a block expression.
@@ -268,6 +265,7 @@ In the case a `loop` has an associated `break`, it is not considered diverging,
268265
[_BlockExpression_]: block-expr.md
269266
[_Expression_]: ../expressions.md
270267
[_Pattern_]: ../patterns.md
268+
[_Scrutinee_]: match-expr.md
271269
[`match` expression]: match-expr.md
272270
[boolean]: ../types/boolean.md
273271
[scrutinee]: ../glossary.md#scrutinee

0 commit comments

Comments
 (0)