2024-11-20 04:30:35 +00:00
|
|
|
// Note: It is no longer true that both `Eq` and `PartialEq` must the derived, only the later.
|
|
|
|
|
|
2016-03-25 10:02:56 -04:00
|
|
|
#[derive(Eq)]
|
|
|
|
|
struct Foo {
|
|
|
|
|
x: u32
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl PartialEq for Foo {
|
|
|
|
|
fn eq(&self, _: &Foo) -> bool {
|
2022-12-05 16:42:36 +08:00
|
|
|
false // ha ha!
|
2016-03-25 10:02:56 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const FOO: Foo = Foo { x: 0 };
|
|
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
|
let y = Foo { x: 1 };
|
|
|
|
|
match y {
|
|
|
|
|
FOO => { }
|
2024-11-20 04:30:35 +00:00
|
|
|
//~^ ERROR constant of non-structural type `Foo` in a pattern
|
2016-03-25 10:02:56 -04:00
|
|
|
_ => { }
|
|
|
|
|
}
|
|
|
|
|
}
|