Skip to content

Commit

Permalink
Update for review.
Browse files Browse the repository at this point in the history
  • Loading branch information
ehuss committed Jan 27, 2019
1 parent 7a62830 commit 38787e4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
12 changes: 5 additions & 7 deletions src/expressions/if-expr.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,10 @@ assert_eq!(y, "Bigger");
An `if let` expression is semantically similar to an `if` expression but in
place of a condition expression it expects the keyword `let` followed by a
pattern, an `=` and an expression. If the value of the expression on the right
hand side of the `=` matches the pattern, the corresponding block will
execute, otherwise flow proceeds to the following `else` block if it exists.
Like `if` expressions, `if let` expressions have a value determined by the
block that is evaluated.
pattern, an `=` and a [scrutinee] expression. If the value of the scrutinee
matches the pattern, the corresponding block will execute. Otherwise, flow
proceeds to the following `else` block if it exists. Like `if` expressions,
`if let` expressions have a value determined by the block that is evaluated.

```rust
let dish = ("Ham", "Eggs");
Expand All @@ -75,8 +74,6 @@ if let ("Ham", b) = dish {
println!("Ham is served with {}", b);
}

// Irrefutable patterns are allowed primarily to make it easier for macros to
// accept any kind of pattern.
if let _ = 5 {
println!("Irrefutable patterns are always true");
}
Expand Down Expand Up @@ -142,3 +139,4 @@ if let PAT = ( EXPR || EXPR ) { .. }
[_Pattern_]: patterns.html
[_LazyBooleanOperatorExpression_]: expressions/operator-expr.html#lazy-boolean-operators
[_eRFCIfLetChain_]: https://github.com/rust-lang/rfcs/blob/master/text/2497-if-let-chains.md#rollout-plan-and-transitioning-to-rust-2018
[scrutinee]: glossary.html#scrutinee
8 changes: 3 additions & 5 deletions src/expressions/loop-expr.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ while i < 10 {
A `while let` loop is semantically similar to a `while` loop but in place of a
condition expression it expects the keyword `let` followed by a pattern, an
`=`, a [scrutinee] expression and a block expression. If the value of the
expression on the right hand side of the `=` matches the pattern, the loop
body block executes then control returns to the pattern matching statement.
Otherwise, the while expression completes.
scrutinee matches the pattern, the loop body block executes then control
returns to the pattern matching statement. Otherwise, the while expression
completes.

```rust
let mut x = vec![1, 2, 3];
Expand All @@ -84,8 +84,6 @@ while let Some(y) = x.pop() {
println!("y = {}", y);
}

// Irrefutable patterns are allowed primarily to make it easier for macros to
// accept any kind of pattern.
while let _ = 5 {
println!("Irrefutable patterns are always true");
break;
Expand Down

0 comments on commit 38787e4

Please sign in to comment.