-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
T-langRelevant to the language team, which will review and decide on the RFC.Relevant to the language team, which will review and decide on the RFC.
Description
Array patterns currently match on either &[T]
or [T, ..n]
:
let x: &[int] = &[1, 2, 3];
let y: Box<[int]> = box [1, 2, 3];
let z: [int, ..3] = [1, 2, 3];
// Does not work
match x {
&[1, 2, 3] => {},
_ => {},
}
// Does not work
match y {
box [1, 2, 3] => {},
_ => {},
}
// Does work
match z {
[1, 2, 3] => {},
_ => {},
}
// Does work
match x {
[1, 2, 3] => {},
_ => {},
}
Logically, array patterns should only work on the bare array types, [T, ..n]
and [T]
. That would mean that all array patterns that match on &[T]
would have to be prefixed by &
, but it would also allow matching on Box<[T]>
(and hypothetically, Rc<[T]>
, Arc<[T]>
etc. eventually). Has this already been considered (perhaps as part of DST)?
Metadata
Metadata
Assignees
Labels
T-langRelevant to the language team, which will review and decide on the RFC.Relevant to the language team, which will review and decide on the RFC.