mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-30 14:01:51 +00:00
36 lines
525 B
Rust
36 lines
525 B
Rust
use std::ops::Deref;
|
|
|
|
struct Foo {
|
|
v: Vec<u32>,
|
|
}
|
|
|
|
struct Bar {
|
|
v: Vec<u32>,
|
|
}
|
|
|
|
impl Deref for Bar {
|
|
type Target = Vec<u32>;
|
|
|
|
fn deref(&self) -> &Self::Target {
|
|
&self.v
|
|
}
|
|
}
|
|
|
|
fn f(foo: &Foo) {
|
|
match foo {
|
|
Foo { v: [1, 2] } => {}
|
|
//~^ ERROR expected an array or slice, found `Vec<u32>
|
|
_ => {}
|
|
}
|
|
}
|
|
|
|
fn bar(bar: &Bar) {
|
|
match bar {
|
|
Bar { v: [1, 2] } => {}
|
|
//~^ ERROR expected an array or slice, found `Vec<u32>
|
|
_ => {}
|
|
}
|
|
}
|
|
|
|
fn main() {}
|