mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-29 02:03:53 +00:00
slice_patterns: adjust error codes
This commit is contained in:
parent
c41443a2b7
commit
0aebb08115
@ -17,8 +17,6 @@ Ensure that the pattern is consistent with the size of the matched
|
|||||||
array. Additional elements can be matched with `..`:
|
array. Additional elements can be matched with `..`:
|
||||||
|
|
||||||
```
|
```
|
||||||
#![feature(slice_patterns)]
|
|
||||||
|
|
||||||
let r = &[1, 2, 3, 4];
|
let r = &[1, 2, 3, 4];
|
||||||
match r {
|
match r {
|
||||||
&[a, b, ..] => { // ok!
|
&[a, b, ..] => { // ok!
|
||||||
|
@ -4,8 +4,6 @@ matched array.
|
|||||||
Example of erroneous code:
|
Example of erroneous code:
|
||||||
|
|
||||||
```compile_fail,E0528
|
```compile_fail,E0528
|
||||||
#![feature(slice_patterns)]
|
|
||||||
|
|
||||||
let r = &[1, 2];
|
let r = &[1, 2];
|
||||||
match r {
|
match r {
|
||||||
&[a, b, c, rest @ ..] => { // error: pattern requires at least 3
|
&[a, b, c, rest @ ..] => { // error: pattern requires at least 3
|
||||||
@ -19,8 +17,6 @@ Ensure that the matched array has at least as many elements as the pattern
|
|||||||
requires. You can match an arbitrary number of remaining elements with `..`:
|
requires. You can match an arbitrary number of remaining elements with `..`:
|
||||||
|
|
||||||
```
|
```
|
||||||
#![feature(slice_patterns)]
|
|
||||||
|
|
||||||
let r = &[1, 2, 3, 4, 5];
|
let r = &[1, 2, 3, 4, 5];
|
||||||
match r {
|
match r {
|
||||||
&[a, b, c, rest @ ..] => { // ok!
|
&[a, b, c, rest @ ..] => { // ok!
|
||||||
|
@ -18,8 +18,6 @@ Ensure that the pattern is consistent with the size of the matched
|
|||||||
array. Additional elements can be matched with `..`:
|
array. Additional elements can be matched with `..`:
|
||||||
|
|
||||||
```
|
```
|
||||||
#![feature(slice_patterns)]
|
|
||||||
|
|
||||||
let r = &[1, 2, 3, 4];
|
let r = &[1, 2, 3, 4];
|
||||||
match r {
|
match r {
|
||||||
&[a, b, ..] => { // ok!
|
&[a, b, ..] => { // ok!
|
||||||
|
Loading…
Reference in New Issue
Block a user