Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify pattern types in let statements and for expressions #663

Merged
merged 1 commit into from
Aug 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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