Skip to content

Commit 58ce407

Browse files
committed
Update RFC.
Add link to prototype implementation. Add note that destructuring bind is not affected by the change proposed here. Account for change in type syntax from `[E, ..k]` to `[E; k]`.
1 parent 7dc78c2 commit 58ce407

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

text/0000-no-array-elem-moves.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ In order to prepare for an expected future implementation of
99

1010
* moving individual elements into an *uninitialized* fixed-sized array, and
1111

12-
* moving individual elements out of fixed-sized arrays `[T, ..n]`,
12+
* moving individual elements out of fixed-sized arrays `[T; n]`,
1313
(copying and borrowing such elements is still permitted).
1414

1515
[non-zeroing dynamic drop]: https://github.com/rust-lang/rfcs/pull/320
@@ -36,19 +36,24 @@ will present relatively little burden.
3636

3737
# Detailed design
3838

39-
If an expression `e` has type `[T, ..n]` and `T` does not implement
39+
If an expression `e` has type `[T; n]` and `T` does not implement
4040
`Copy`, then it will be illegal to use `e[i]` in an r-value position.
4141

42-
If an expression `e` has type `[T, ..n]` expression `e[i] = <expr>`
42+
If an expression `e` has type `[T; n]` expression `e[i] = <expr>`
4343
will be made illegal at points in the control flow where `e` has not
4444
yet been initialized.
4545

4646
Note that it *remains* legal to overwrite an element in an initialized
4747
array: `e[i] = <expr>`, as today. This will continue to drop the
4848
overwritten element before moving the result of `<expr>` into place.
4949

50-
A prototype implementation will be made available before this RFC is
51-
accepted.
50+
Note also that the proposed change has no effect on the semantics of
51+
destructuring bind; i.e. `fn([a, b, c]: [Elem; 3]) { ... }` will
52+
continue to work as much as it does today.
53+
54+
A prototype implementation has been posted at [Rust PR 21930].
55+
56+
[Rust PR 21930]: https://github.com/rust-lang/rust/pull/21930
5257

5358
# Drawbacks
5459

@@ -62,11 +67,13 @@ Also, as noted in the [comment thread from RFC PR 320]
6267
[comment thread from RFC PR 320]: https://github.com/rust-lang/rfcs/pull/320#issuecomment-59533551
6368

6469
* We support moving a single element out of an n-tuple, and "by
65-
analogy" we should support moving out of `[T, ..n]`
70+
analogy" we should support moving out of `[T; n]`
71+
(Note that one can still move out of `[T; n]` in some cases
72+
via destructuring bind.)
6673

6774
* It is "nice" to be able to write
6875
```rust
69-
fn grab_random_from(actions: [Action, ..5]) -> Action { actions[rand_index()] }
76+
fn grab_random_from(actions: [Action; 5]) -> Action { actions[rand_index()] }
7077
```
7178
to express this now, one would be forced to instead use clone() (or
7279
pass in a `Vec` and do some element swapping).

0 commit comments

Comments
 (0)