Skip to content

Commit

Permalink
Merge pull request #663 from hawkinsw/label_pattern_refutability
Browse files Browse the repository at this point in the history
 Specify pattern types in `let` statements and `for` expressions
  • Loading branch information
Centril authored Aug 29, 2019
2 parents 5e7f5cf + 11b950a commit 6f0bdab
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/expressions/loop-expr.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ while let Some(v @ 1) | Some(v @ 2) = vals.pop() {
A `for` expression is a syntactic construct for looping over elements provided
by an implementation of `std::iter::IntoIterator`. If the iterator yields a
value, that value is given the specified name and the body of the loop is
executed, then control returns to the head of the `for` loop. If the iterator
is empty, the `for` expression completes.
value, that value is matched against the irrefutable pattern, the body of the
loop is executed, and then control returns to the head of the `for` loop. If the
iterator is empty, the `for` expression completes.

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

Expand Down
14 changes: 7 additions & 7 deletions src/statements.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ fn outer() {
> &nbsp;&nbsp; [_OuterAttribute_]<sup>\*</sup> `let` [_Pattern_]
> ( `:` [_Type_] )<sup>?</sup> (`=` [_Expression_] )<sup>?</sup> `;`
A *`let` statement* introduces a new set of [variables], given by a [pattern]. The
pattern is followed optionally by a type annotation and then optionally by an
initializer expression. When no type annotation is given, the compiler will
infer the type, or signal an error if insufficient type information is
available for definite inference. Any variables introduced by a variable
declaration are visible from the point of declaration until the end of the
enclosing block scope.
A *`let` statement* introduces a new set of [variables], given by an
irrefutable [pattern]. The pattern is followed optionally by a type
annotation and then optionally by an initializer expression. When no
type annotation is given, the compiler will infer the type, or signal
an error if insufficient type information is available for definite
inference. Any variables introduced by a variable declaration are visible
from the point of declaration until the end of the enclosing block scope.

## Expression statements

Expand Down

0 comments on commit 6f0bdab

Please sign in to comment.