Skip to content

Commit 7120df9

Browse files
committed
Make clarifications after review
1 parent ff995bb commit 7120df9

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

text/0000-destructuring-assignment.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ accepted:
1313
```rust
1414
(a, (b.x.y, c)) = (0, (1, 2));
1515
(x, y, .., z) = (1.0, 2.0, 3.0, 4.0, 5.0);
16-
[_, f, *baz()] = foo();
16+
[_, f, *baz(), a[i]] = foo();
1717
[g, _, h, ..] = ['a', 'w', 'e', 's', 'o', 'm', 'e', '!'];
1818
Struct { x: a, y: b } = bar();
1919
Struct { x, y } = Struct { x: 5, y: 6 };
@@ -128,7 +128,7 @@ identifiers are fresh and thus do not conflict with existing variables). A nice
128128
we inherit the diagnostics for normal pattern-matching, so users benefit from existing diagnostics
129129
for destructuring declarations.
130130

131-
Nested structures are destructured appropriately, for instance:
131+
Nested structures may be destructured, for instance:
132132

133133
```rust
134134
let (a, b, c);
@@ -152,6 +152,11 @@ Note that `#[non_exhaustive]` must be taken into account properly: enums marked
152152
may not have their variants destructured, and structs marked `#[non_exhaustive]` may only be
153153
destructured using `..`.
154154

155+
Patterns must be irrefutable. In particular, only slice patterns whose length is known at compile-
156+
time, and the trivial slice `[..]` may be used for destructuring assignment.
157+
158+
As expected from the desugaring, the default binding modes of normal `let` destructuring applying.
159+
155160
## Diagnostics
156161

157162
It is worth being explicit that, in the implementation, the diagnostics that are reported are

0 commit comments

Comments
 (0)