Skip to content

Commit 116cb2a

Browse files
committed
[T, ..n] => [T; n]
1 parent 221414d commit 116cb2a

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

text/0000-array-pattern-changes.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ Summary
77

88
Change array/slice patterns in the following ways:
99

10-
- Make them only match on arrays (`[T, ..n]` and `[T]`), not slices;
11-
- Make subslice matching yield a value of type `[T, ..n]` or `[T]`, not `&[T]`
12-
or `&mut [T]`;
10+
- Make them only match on arrays (`[T; n]` and `[T]`), not slices;
11+
- Make subslice matching yield a value of type `[T; n]` or `[T]`, not `&[T]` or
12+
`&mut [T]`;
1313
- Allow multiple mutable references to be made to different parts of the same
1414
array or slice in array patterns (resolving rust-lang/rust [issue
1515
#8636](https://github.com/rust-lang/rust/issues/8636)).
@@ -21,9 +21,9 @@ Before DST (and after the removal of `~[T]`), there were only two types based on
2121
`[T]`: `&[T]` and `&mut [T]`. With DST, we can have many more types based on
2222
`[T]`, `Box<[T]>` in particular, but theoretically any pointer type around a
2323
`[T]` could be used. However, array patterns still match on `&[T]`, `&mut [T]`,
24-
and `[T, ..n]` only, meaning that to match on a `Box<[T]>`, one must first
25-
convert it to a slice, which disallows moves. This may prove to significantly
26-
limit the amount of useful code that can be written using array patterns.
24+
and `[T; n]` only, meaning that to match on a `Box<[T]>`, one must first convert
25+
it to a slice, which disallows moves. This may prove to significantly limit the
26+
amount of useful code that can be written using array patterns.
2727

2828
Another problem with today’s array patterns is in subslice matching, which
2929
specifies that the rest of a slice not matched on already in the pattern should
@@ -66,7 +66,7 @@ multiple mutable borrows to the same value (which is not the case).
6666
Detailed design
6767
===============
6868

69-
- Make array patterns match only on arrays (`[T, ..n]` and `[T]`). For example,
69+
- Make array patterns match only on arrays (`[T; n]` and `[T]`). For example,
7070
the following code:
7171

7272
```rust
@@ -89,7 +89,7 @@ Detailed design
8989

9090
This change makes slice patterns mirror slice expressions much more closely.
9191

92-
- Make subslice matching in array patterns yield a value of type `[T, ..n]` (if
92+
- Make subslice matching in array patterns yield a value of type `[T; n]` (if
9393
the array is of fixed size) or `[T]` (if not). This means changing most code
9494
that looks like this:
9595

@@ -112,8 +112,8 @@ Detailed design
112112
```
113113

114114
It should be noted that if a fixed-size array is matched on using subslice
115-
matching, and `ref` is used, the type of the binding will be `&[T, ..n]`,
116-
*not* `&[T]`.
115+
matching, and `ref` is used, the type of the binding will be `&[T; n]`, *not*
116+
`&[T]`.
117117

118118
- Improve the compiler’s analysis of multiple mutable references to the same
119119
value within array patterns. This would be done by allowing multiple mutable

0 commit comments

Comments
 (0)