2023-11-16 18:55:55 -06:00
|
|
|
fn main() {
|
|
|
|
match &[1, 2, 3][..] {
|
2024-02-02 18:32:01 -06:00
|
|
|
[1, rest..] => println!("{rest}"),
|
2023-11-16 18:55:55 -06: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-02 18:32:01 -06: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-16 18:55:55 -06:00
|
|
|
}
|