Skip to content

Commit 599d134

Browse files
committed
Address comments
1 parent 7db1f5a commit 599d134

File tree

3 files changed

+23
-37
lines changed

3 files changed

+23
-37
lines changed

src/SUMMARY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
- [Match expressions](expressions/match-expr.md)
6767
- [Return expressions](expressions/return-expr.md)
6868
- [Await expressions](expressions/await-expr.md)
69-
- [Underscore expression](expressions/underscore-expr.md)
69+
- [Underscore expressions](expressions/underscore-expr.md)
7070

7171
- [Patterns](patterns.md)
7272

src/expressions/operator-expr.md

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -428,20 +428,15 @@ assert_eq!(values[1], 3);
428428
429429
An *assignment expression* moves a value into a specified place.
430430

431-
An assignment expression consists of a [mutable] [assignee expression], the
432-
*assignee operand*, followed by an equals sign (`=`) and a [value expression],
433-
the *assigned value operand*. In its most basic form, an assignee expression is
434-
a [place expression], and we discuss this case first. The more general case of
435-
destructuring assignment is discussed below, but this case always decomposes
436-
into sequential assignments to place expressions, which may be considered the
437-
more fundamental case.
431+
An assignment expression consists of a [mutable] [assignee expression], the *assignee operand*, followed by an equals sign (`=`) and a [value expression], the *assigned value operand*.
432+
In its most basic form, an assignee expression is a [place expression], and we discuss this case first.
433+
The more general case of destructuring assignment is discussed below, but this case always decomposes into sequential assignments to place expressions, which may be considered the more fundamental case.
438434

439435
### Basic assignments
440436

441-
Evaluating assignment expressions begins by evaluating its operands. The
442-
assigned value operand is evaluated first, followed by the assignee expression.
443-
(For destructuring assignment, subexpressions of the assignee expression are
444-
evaluated left-to-right.)
437+
Evaluating assignment expressions begins by evaluating its operands.
438+
The assigned value operand is evaluated first, followed by the assignee expression.
439+
For destructuring assignment, subexpressions of the assignee expression are evaluated left-to-right.
445440

446441
> **Note**: This is different than other expressions in that the right operand is evaluated before the left one.
447442
@@ -460,29 +455,25 @@ x = y;
460455

461456
### Destructuring assignments
462457

463-
Destructuring assignment is a counterpart to destructuring pattern matches for
464-
variable declaration, permitting assignment to complex values, such as tuples or
465-
structs. For instance, we may swap two mutable variables:
458+
Destructuring assignment is a counterpart to destructuring pattern matches for variable declaration, permitting assignment to complex values, such as tuples or structs.
459+
For instance, we may swap two mutable variables:
466460

467-
```rust,ignore
461+
```rust
468462
let (mut a, mut b) = (0, 1);
469463
// Swap `a` and `b` using destructuring assignment.
470464
(b, a) = (a, b);
471465
```
472466

473-
In contrast to destructuring declarations using `let`, patterns may not appear
474-
on the left-hand side of an assignment due to syntactic ambiguities. Instead, a
475-
group of expressions that correspond to patterns are designated to be [assignee
476-
expressions][assignee expression], and permitted on the left-hand side of an
477-
assignment. Assignee expressions are then desugared to pattern matches followed
478-
by sequential assignment. The desugared patterns must be irrefutable: in
479-
particular, this means that only slice patterns whose length is known at
480-
compile-time, and the trivial slice `[..]`, are permitted for destructuring
481-
assignment.
467+
In contrast to destructuring declarations using `let`, patterns may not appear on the left-hand side of an assignment due to syntactic ambiguities.
468+
Instead, a group of expressions that correspond to patterns are designated to be [assignee expressions][assignee expression], and permitted on the left-hand side of an assignment.
469+
Assignee expressions are then desugared to pattern matches followed by sequential assignment.
470+
The desugared patterns must be irrefutable: in particular, this means that only slice patterns whose length is known at compile-time, and the trivial slice `[..]`, are permitted for destructuring assignment.
482471

483472
The desugaring method is straightforward, and is illustrated best by example.
484473

485-
```rust,ignore
474+
```rust
475+
# struct Struct { x: u32, y: u32 }
476+
# let (mut a, mut b) = (0, 0);
486477
(a, b) = (3, 4);
487478

488479
[a, b] = [3, 4];
@@ -510,12 +501,9 @@ Struct { x: a, y: b } = Struct { x: 3, y: 4};
510501
}
511502
```
512503

513-
Identifiers are not forbidden from being used multiple times in a single
514-
assignee expression.
504+
Identifiers are not forbidden from being used multiple times in a single assignee expression.
515505

516-
[Underscore expressions][_UnderscoreExpression_] and empty [range
517-
expressions][_RangeExpression_] may be used to ignore certain values, without
518-
binding them.
506+
[Underscore expressions][_UnderscoreExpression_] and empty [range expressions][_RangeExpression_] may be used to ignore certain values, without binding them.
519507

520508
Note that default binding modes do not apply for the desugared expression.
521509

src/expressions/underscore-expr.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
1-
# `_` expression
1+
# `_` expressions
22

33
> **<sup>Syntax</sup>**\
44
> _UnderscoreExpression_ :\
55
> &nbsp;&nbsp; `_`
66
7-
The underscore expression, denoted with the symbol `_`, is used to signify a
8-
placeholder in a destructuring assignment. It may only appear in the left-hand
7+
Underscore expressions, denoted with the symbol `_`, are used to signify a
8+
placeholder in a destructuring assignment. They may only appear in the left-hand
99
side of an assignment.
1010

1111
An example of an `_` expression:
1212

13-
```rust,ignore
13+
```rust
1414
let p = (1, 2);
1515
let mut a = 0;
1616
(_, a) = p;
1717
```
18-
19-
[_Expression_]: ../expressions.md

0 commit comments

Comments
 (0)