Skip to content

Commit 6f0bdab

Browse files
authored
Merge pull request #663 from hawkinsw/label_pattern_refutability
Specify pattern types in `let` statements and `for` expressions
2 parents 5e7f5cf + 11b950a commit 6f0bdab

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/expressions/loop-expr.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,9 @@ while let Some(v @ 1) | Some(v @ 2) = vals.pop() {
130130
131131
A `for` expression is a syntactic construct for looping over elements provided
132132
by an implementation of `std::iter::IntoIterator`. If the iterator yields a
133-
value, that value is given the specified name and the body of the loop is
134-
executed, then control returns to the head of the `for` loop. If the iterator
135-
is empty, the `for` expression completes.
133+
value, that value is matched against the irrefutable pattern, the body of the
134+
loop is executed, and then control returns to the head of the `for` loop. If the
135+
iterator is empty, the `for` expression completes.
136136

137137
An example of a `for` loop over the contents of an array:
138138

src/statements.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ fn outer() {
5656
> &nbsp;&nbsp; [_OuterAttribute_]<sup>\*</sup> `let` [_Pattern_]
5757
> ( `:` [_Type_] )<sup>?</sup> (`=` [_Expression_] )<sup>?</sup> `;`
5858
59-
A *`let` statement* introduces a new set of [variables], given by a [pattern]. The
60-
pattern is followed optionally by a type annotation and then optionally by an
61-
initializer expression. When no type annotation is given, the compiler will
62-
infer the type, or signal an error if insufficient type information is
63-
available for definite inference. Any variables introduced by a variable
64-
declaration are visible from the point of declaration until the end of the
65-
enclosing block scope.
59+
A *`let` statement* introduces a new set of [variables], given by an
60+
irrefutable [pattern]. The pattern is followed optionally by a type
61+
annotation and then optionally by an initializer expression. When no
62+
type annotation is given, the compiler will infer the type, or signal
63+
an error if insufficient type information is available for definite
64+
inference. Any variables introduced by a variable declaration are visible
65+
from the point of declaration until the end of the enclosing block scope.
6666

6767
## Expression statements
6868

0 commit comments

Comments
 (0)