Skip to content

Commit 821dcc8

Browse files
committed
Add note about place expressions
1 parent db1a22b commit 821dcc8

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

text/0000-destructuring-assignment.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,10 @@ You may use `_` and `..` as in a normal declaration pattern to ignore certain va
4646
# Reference-level explanation
4747
[reference-level-explanation]: #reference-level-explanation
4848

49-
The feature as described here has been implemented as a proof-of-concept (https://github.com/rust-lang/rust/pull/71156). It follows essentially the
50-
[suggestions of @Kimundi](https://github.com/rust-lang/rfcs/issues/372#issuecomment-214022963) and
51-
[of @drunwald](https://github.com/rust-lang/rfcs/issues/372#issuecomment-262519146).
49+
The feature as described here has been implemented as a proof-of-concept
50+
(https://github.com/rust-lang/rust/pull/71156). It follows essentially the [suggestions of
51+
@Kimundi](https://github.com/rust-lang/rfcs/issues/372#issuecomment-214022963) and [of
52+
@drunwald](https://github.com/rust-lang/rfcs/issues/372#issuecomment-262519146).
5253

5354
The Rust compiler already parses complex expressions on the left-hand side of an assignment, but
5455
does not handle them other than emitting an error later in compilation. We propose to add
@@ -59,6 +60,18 @@ complicates Rust's grammar and it is not clear that it is even technically feasi
5960
handling some classes of expressions is much simpler, and is indistinguishable to users, who will
6061
receive pattern-oriented diagnostics due to the desugaring of expressions into patterns.
6162

63+
In effect, we are extending the [place
64+
expressions](https://doc.rust-lang.org/reference/expressions.html#place-expressions-and-value-expressions) (also called "lvalues")
65+
that Rust accepts by the following:
66+
67+
- Underscore: `_`.
68+
- Tuples: `(place, place, place)`, `(place, .., place)`, `(.., place, place)`, `(place, place, ..)`.
69+
- Slices: `[place, place, place]`, `[place, .., place]`, `[.., place, place]`, `[place, place, ..]`.
70+
- Tuple structs: `path(place, place, place)`, `path(place, .., place)`, `path(.., place, place)`,
71+
`path(place, place, ..)`.
72+
- Structs: `path { field: place, field: place }`, `path { field: place, field: place, .. }`.
73+
- Unit structs: `path`.
74+
6275
The general idea is that we will desugar the following complex assignments as demonstrated.
6376

6477
```rust

0 commit comments

Comments
 (0)