]>
Commit | Line | Data |
---|---|---|
223e47cc LB |
1 | // Copyright 2012 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 | ||
970d7e83 | 11 | |
c34b1796 AL |
12 | |
13 | enum colour { red(isize, isize), green, } | |
223e47cc | 14 | |
1a4d82fc | 15 | impl PartialEq for colour { |
223e47cc LB |
16 | fn eq(&self, other: &colour) -> bool { |
17 | match *self { | |
1a4d82fc | 18 | colour::red(a0, b0) => { |
223e47cc | 19 | match (*other) { |
1a4d82fc JJ |
20 | colour::red(a1, b1) => a0 == a1 && b0 == b1, |
21 | colour::green => false, | |
223e47cc LB |
22 | } |
23 | } | |
1a4d82fc | 24 | colour::green => { |
223e47cc | 25 | match (*other) { |
1a4d82fc JJ |
26 | colour::red(..) => false, |
27 | colour::green => true | |
223e47cc LB |
28 | } |
29 | } | |
30 | } | |
31 | } | |
32 | fn ne(&self, other: &colour) -> bool { !(*self).eq(other) } | |
33 | } | |
34 | ||
1a4d82fc | 35 | fn f() { let x = colour::red(1, 2); let y = colour::green; assert!((x != y)); } |
223e47cc LB |
36 | |
37 | pub fn main() { f(); } |