Clear up the reference around let
First, re-word the section on if let/while let to be more clear. Second, actually call them let statements in the statement section Fixes #29801
This commit is contained in:
parent
57c8a3e8b6
commit
cf384c21ea
1 changed files with 12 additions and 11 deletions
|
@ -2415,9 +2415,9 @@ in meaning to declaring the item outside the statement block.
|
|||
> **Note**: there is no implicit capture of the function's dynamic environment when
|
||||
> declaring a function-local item.
|
||||
|
||||
#### Variable declarations
|
||||
#### `let` statements
|
||||
|
||||
A _variable declaration_ introduces a new set of variable, given by a pattern. The
|
||||
A _`let` statement_ introduces a new set of variables, given by a pattern. The
|
||||
pattern may be followed by a type annotation, and/or 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.
|
||||
|
@ -3190,10 +3190,11 @@ let message = match maybe_digit {
|
|||
|
||||
### `if let` expressions
|
||||
|
||||
An `if let` expression is semantically identical to an `if` expression but in place
|
||||
of a condition expression it expects a refutable let statement. If the value of the
|
||||
expression on the right hand side of the let statement matches the pattern, the corresponding
|
||||
block will execute, otherwise flow proceeds to the first `else` block that follows.
|
||||
An `if let` expression is semantically identical to an `if` expression but in
|
||||
place of a condition expression it expects a `let` statement with a refutable
|
||||
pattern. If the value of the expression on the right hand side of the `let`
|
||||
statement matches the pattern, the corresponding block will execute, otherwise
|
||||
flow proceeds to the first `else` block that follows.
|
||||
|
||||
```
|
||||
let dish = ("Ham", "Eggs");
|
||||
|
@ -3211,11 +3212,11 @@ if let ("Ham", b) = dish {
|
|||
|
||||
### `while let` loops
|
||||
|
||||
A `while let` loop is semantically identical to a `while` loop but in place of a
|
||||
condition expression it expects a refutable let statement. If the value of the
|
||||
expression on the right hand side of the let statement matches the pattern, the
|
||||
loop body block executes and control returns to the pattern matching statement.
|
||||
Otherwise, the while expression completes.
|
||||
A `while let` loop is semantically identical to a `while` loop but in place of
|
||||
a condition expression it expects `let` statement with a refutable pattern. If
|
||||
the value of the expression on the right hand side of the `let` statement
|
||||
matches the pattern, the loop body block executes and control returns to the
|
||||
pattern matching statement. Otherwise, the while expression completes.
|
||||
|
||||
### `return` expressions
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue