]> git.lizzy.rs Git - rust.git/blob - src/test/ui/binop/structured-compare.rs
:arrow_up: rust-analyzer
[rust.git] / src / test / ui / binop / structured-compare.rs
1 // run-pass
2
3 #![allow(non_camel_case_types)]
4
5
6 #[derive(Copy, Clone, Debug)]
7 enum foo { large, small, }
8
9 impl PartialEq for foo {
10     fn eq(&self, other: &foo) -> bool {
11         ((*self) as usize) == ((*other) as usize)
12     }
13     fn ne(&self, other: &foo) -> bool { !(*self).eq(other) }
14 }
15
16 pub fn main() {
17     let a = (1, 2, 3);
18     let b = (1, 2, 3);
19     assert_eq!(a, b);
20     assert!((a != (1, 2, 4)));
21     assert!((a < (1, 2, 4)));
22     assert!((a <= (1, 2, 4)));
23     assert!(((1, 2, 4) > a));
24     assert!(((1, 2, 4) >= a));
25     let x = foo::large;
26     let y = foo::small;
27     assert!((x != y));
28     assert_eq!(x, foo::large);
29     assert!((x != foo::small));
30 }