2011-06-15 13:19:50 -05:00
|
|
|
|
|
|
|
|
2012-01-19 20:31:08 -06:00
|
|
|
enum foo { large, small, }
|
2010-09-21 13:47:10 -05:00
|
|
|
|
2012-08-27 18:26:35 -05:00
|
|
|
impl foo : cmp::Eq {
|
2012-09-19 20:00:26 -05:00
|
|
|
pure fn eq(other: &foo) -> bool {
|
|
|
|
(self as uint) == ((*other) as uint)
|
2012-08-27 18:26:35 -05:00
|
|
|
}
|
2012-09-19 20:00:26 -05:00
|
|
|
pure fn ne(other: &foo) -> bool { !self.eq(other) }
|
2012-08-27 18:26:35 -05:00
|
|
|
}
|
|
|
|
|
2010-09-21 13:47:10 -05:00
|
|
|
fn main() {
|
2012-08-27 18:26:35 -05:00
|
|
|
let a = (1, 2, 3);
|
|
|
|
let b = (1, 2, 3);
|
2011-06-15 13:19:50 -05:00
|
|
|
assert (a == b);
|
2012-08-27 18:26:35 -05:00
|
|
|
assert (a != (1, 2, 4));
|
|
|
|
assert (a < (1, 2, 4));
|
|
|
|
assert (a <= (1, 2, 4));
|
|
|
|
assert ((1, 2, 4) > a);
|
|
|
|
assert ((1, 2, 4) >= a);
|
2011-07-27 07:19:39 -05:00
|
|
|
let x = large;
|
|
|
|
let y = small;
|
2011-06-15 13:19:50 -05:00
|
|
|
assert (x != y);
|
|
|
|
assert (x == large);
|
|
|
|
assert (x != small);
|
2011-08-19 17:16:48 -05:00
|
|
|
}
|