2022-04-17 23:08:23 -05:00
|
|
|
use std::ops::Deref;
|
|
|
|
|
2022-04-16 11:20:11 -05:00
|
|
|
struct Foo {
|
|
|
|
v: Vec<u32>,
|
|
|
|
}
|
|
|
|
|
2022-04-17 23:08:23 -05:00
|
|
|
struct Bar {
|
|
|
|
v: Vec<u32>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Deref for Bar {
|
|
|
|
type Target = Vec<u32>;
|
|
|
|
|
|
|
|
fn deref(&self) -> &Self::Target {
|
|
|
|
&self.v
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-16 11:20:11 -05:00
|
|
|
fn f(foo: &Foo) {
|
|
|
|
match foo {
|
|
|
|
Foo { v: [1, 2] } => {}
|
|
|
|
//~^ ERROR expected an array or slice, found `Vec<u32>
|
|
|
|
_ => {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-17 23:08:23 -05:00
|
|
|
fn bar(bar: &Bar) {
|
|
|
|
match bar {
|
|
|
|
Bar { v: [1, 2] } => {}
|
|
|
|
//~^ ERROR expected an array or slice, found `Vec<u32>
|
|
|
|
_ => {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-16 11:20:11 -05:00
|
|
|
fn main() {}
|