]>
Commit | Line | Data |
---|---|---|
1a4d82fc JJ |
1 | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT |
2 | // file at the top-level directory of this distribution and at | |
3 | // http://rust-lang.org/COPYRIGHT. | |
4 | // | |
5 | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | |
6 | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | |
7 | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | |
8 | // option. This file may not be copied, modified, or distributed | |
9 | // except according to those terms. | |
10 | ||
c34b1796 | 11 | |
62682a34 | 12 | #[derive(PartialEq, Debug)] |
1a4d82fc | 13 | struct Bar; |
62682a34 | 14 | #[derive(Debug)] |
1a4d82fc | 15 | struct Baz; |
62682a34 | 16 | #[derive(Debug)] |
1a4d82fc | 17 | struct Foo; |
62682a34 | 18 | #[derive(Debug)] |
1a4d82fc JJ |
19 | struct Fu; |
20 | ||
21 | impl PartialEq for Baz { fn eq(&self, _: &Baz) -> bool { true } } | |
22 | ||
23 | impl PartialEq<Fu> for Foo { fn eq(&self, _: &Fu) -> bool { true } } | |
24 | impl PartialEq<Foo> for Fu { fn eq(&self, _: &Foo) -> bool { true } } | |
25 | ||
26 | impl PartialEq<Bar> for Foo { fn eq(&self, _: &Bar) -> bool { false } } | |
27 | impl PartialEq<Foo> for Bar { fn eq(&self, _: &Foo) -> bool { false } } | |
28 | ||
29 | fn main() { | |
30 | assert!(Bar != Foo); | |
31 | assert!(Foo != Bar); | |
32 | ||
62682a34 | 33 | assert_eq!(Bar, Bar); |
1a4d82fc | 34 | |
62682a34 | 35 | assert_eq!(Baz, Baz); |
1a4d82fc | 36 | |
62682a34 SL |
37 | assert_eq!(Foo, Fu); |
38 | assert_eq!(Fu, Foo); | |
1a4d82fc | 39 | } |