]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/tag.rs
Auto merge of #28816 - petrochenkov:unistruct, r=nrc
[rust.git] / src / test / run-pass / tag.rs
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
11
12
13 enum colour { red(isize, isize), green, }
14
15 impl PartialEq for colour {
16     fn eq(&self, other: &colour) -> bool {
17         match *self {
18             colour::red(a0, b0) => {
19                 match (*other) {
20                     colour::red(a1, b1) => a0 == a1 && b0 == b1,
21                     colour::green => false,
22                 }
23             }
24             colour::green => {
25                 match (*other) {
26                     colour::red(..) => false,
27                     colour::green => true
28                 }
29             }
30         }
31     }
32     fn ne(&self, other: &colour) -> bool { !(*self).eq(other) }
33 }
34
35 fn f() { let x = colour::red(1, 2); let y = colour::green; assert!((x != y)); }
36
37 pub fn main() { f(); }