2023-11-17 00:55:55 +00:00
|
|
|
fn main() {
|
|
|
|
match &[1, 2, 3][..] {
|
2024-02-03 00:32:01 +00:00
|
|
|
[1, rest..] => println!("{rest}"),
|
2023-11-17 00:55:55 +00:00
|
|
|
//~^ ERROR cannot find value `rest` in this scope
|
|
|
|
//~| ERROR cannot find value `rest` in this scope
|
|
|
|
//~| ERROR `X..` patterns in slices are experimental
|
|
|
|
_ => {}
|
|
|
|
}
|
2024-02-03 00:32:01 +00:00
|
|
|
match &[4, 5, 6][..] {
|
|
|
|
[] => {}
|
|
|
|
[_, ..tail] => println!("{tail}"),
|
|
|
|
//~^ ERROR cannot find value `tail` in this scope
|
|
|
|
//~| ERROR cannot find value `tail` in this scope
|
|
|
|
//~| ERROR exclusive range pattern syntax is experimental
|
|
|
|
}
|
|
|
|
match &[7, 8, 9][..] {
|
|
|
|
[] => {}
|
|
|
|
[_, ...tail] => println!("{tail}"),
|
|
|
|
//~^ ERROR cannot find value `tail` in this scope
|
|
|
|
//~| ERROR cannot find value `tail` in this scope
|
|
|
|
//~| ERROR range-to patterns with `...` are not allowed
|
|
|
|
}
|
2023-11-17 00:55:55 +00:00
|
|
|
}
|