rust/tests/ui/suggestions/pattern-struct-with-slice-vec-field.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

36 lines
525 B
Rust
Raw Normal View History

2022-04-18 04:08:23 +00:00
use std::ops::Deref;
struct Foo {
v: Vec<u32>,
}
2022-04-18 04:08:23 +00:00
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>
_ => {}
}
}
2022-04-18 04:08:23 +00:00
fn bar(bar: &Bar) {
match bar {
Bar { v: [1, 2] } => {}
//~^ ERROR expected an array or slice, found `Vec<u32>
_ => {}
}
}
fn main() {}