@@ -46,9 +46,10 @@ You may use `_` and `..` as in a normal declaration pattern to ignore certain va
46
46
# Reference-level explanation
47
47
[ reference-level-explanation ] : #reference-level-explanation
48
48
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 ) .
52
53
53
54
The Rust compiler already parses complex expressions on the left-hand side of an assignment, but
54
55
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
59
60
handling some classes of expressions is much simpler, and is indistinguishable to users, who will
60
61
receive pattern-oriented diagnostics due to the desugaring of expressions into patterns.
61
62
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
+
62
75
The general idea is that we will desugar the following complex assignments as demonstrated.
63
76
64
77
``` rust
0 commit comments