]> git.proxmox.com Git - rustc.git/blob - src/test/run-pass/eq-multidispatch.rs
bf8b089a830c2c662eb2d9dcbe253950679b704e
[rustc.git] / src / test / run-pass / eq-multidispatch.rs
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
11
12 #[derive(PartialEq)]
13 struct Bar;
14 struct Baz;
15 struct Foo;
16 struct Fu;
17
18 impl PartialEq for Baz { fn eq(&self, _: &Baz) -> bool { true } }
19
20 impl PartialEq<Fu> for Foo { fn eq(&self, _: &Fu) -> bool { true } }
21 impl PartialEq<Foo> for Fu { fn eq(&self, _: &Foo) -> bool { true } }
22
23 impl PartialEq<Bar> for Foo { fn eq(&self, _: &Bar) -> bool { false } }
24 impl PartialEq<Foo> for Bar { fn eq(&self, _: &Foo) -> bool { false } }
25
26 fn main() {
27 assert!(Bar != Foo);
28 assert!(Foo != Bar);
29
30 assert!(Bar == Bar);
31
32 assert!(Baz == Baz);
33
34 assert!(Foo == Fu);
35 assert!(Fu == Foo);
36 }