blob: c67a72e90c9e15a6c52a7b9b7c38086450dc4a6f [file] [log] [blame]
Graydon Hoared1affff2012-12-11 01:32:481// 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
Graydon Hoarece729932011-06-15 18:19:5011
12
Patrick Walton59ebe6a2012-01-20 02:31:0813enum foo { large, small, }
Graydon Hoare9f0a6c22010-09-21 18:47:1014
Patrick Walton206ab892013-05-25 02:35:2915impl Eq for foo {
Patrick Walton3eda11a2013-03-22 18:23:2116 fn eq(&self, other: &foo) -> bool {
Patrick Walton318e5342012-11-15 02:59:3017 ((*self) as uint) == ((*other) as uint)
Patrick Walton96534362012-08-27 23:26:3518 }
Patrick Walton3eda11a2013-03-22 18:23:2119 fn ne(&self, other: &foo) -> bool { !(*self).eq(other) }
Patrick Walton96534362012-08-27 23:26:3520}
21
Graydon Hoare89c8ef72013-02-02 03:43:1722pub fn main() {
Patrick Walton96534362012-08-27 23:26:3523 let a = (1, 2, 3);
24 let b = (1, 2, 3);
Corey Richardsoncc57ca02013-05-19 02:02:4525 assert_eq!(a, b);
Patrick Walton1e915952013-03-29 01:39:0926 assert!((a != (1, 2, 4)));
27 assert!((a < (1, 2, 4)));
28 assert!((a <= (1, 2, 4)));
29 assert!(((1, 2, 4) > a));
30 assert!(((1, 2, 4) >= a));
Marijn Haverbekedf7f21d2011-07-27 12:19:3931 let x = large;
32 let y = small;
Patrick Walton1e915952013-03-29 01:39:0933 assert!((x != y));
Corey Richardsoncc57ca02013-05-19 02:02:4534 assert_eq!(x, large);
Patrick Walton1e915952013-03-29 01:39:0935 assert!((x != small));
Brian Anderson518dc522011-08-19 22:16:4836}