7
7
8
8
Change array/slice patterns in the following ways:
9
9
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] ` ;
13
13
- Allow multiple mutable references to be made to different parts of the same
14
14
array or slice in array patterns (resolving rust-lang/rust [ issue
15
15
#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
21
21
` [T] ` : ` &[T] ` and ` &mut [T] ` . With DST, we can have many more types based on
22
22
` [T] ` , ` Box<[T]> ` in particular, but theoretically any pointer type around a
23
23
` [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.
27
27
28
28
Another problem with today’s array patterns is in subslice matching, which
29
29
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).
66
66
Detailed design
67
67
===============
68
68
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,
70
70
the following code:
71
71
72
72
``` rust
@@ -89,7 +89,7 @@ Detailed design
89
89
90
90
This change makes slice patterns mirror slice expressions much more closely.
91
91
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
93
93
the array is of fixed size) or ` [T] ` (if not). This means changing most code
94
94
that looks like this:
95
95
@@ -112,8 +112,8 @@ Detailed design
112
112
```
113
113
114
114
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] ` .
117
117
118
118
- Improve the compiler’s analysis of multiple mutable references to the same
119
119
value within array patterns. This would be done by allowing multiple mutable
0 commit comments