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