diff options
| author | Steve Klabnik <steve@steveklabnik.com> | 2015-11-17 18:13:05 -0500 |
|---|---|---|
| committer | Steve Klabnik <steve@steveklabnik.com> | 2015-11-17 18:13:05 -0500 |
| commit | 8adfcf1b7c9a4e4c59eebd27027b3379740555e9 (patch) | |
| tree | db4816f2bdcb7d8b1ef1f9581eb89561841809cc | |
| parent | fb6687150c9e89e0b0876e986a954fd647781499 (diff) | |
| parent | cf384c21eae3f9bd7e8d1f76ced8ad7199cd02f4 (diff) | |
| download | rust-8adfcf1b7c9a4e4c59eebd27027b3379740555e9.tar.gz rust-8adfcf1b7c9a4e4c59eebd27027b3379740555e9.zip | |
Rollup merge of #29889 - steveklabnik:gh29801, r=manishearth
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
| -rw-r--r-- | src/doc/reference.md | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/doc/reference.md b/src/doc/reference.md index de9352a4275..b057b846be7 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -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 |
