rust/tests/ui/suggestions/pattern-struct-with-slice-vec-field.rs
2023-01-11 09:32:08 +00:00

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() {}