]>
Commit | Line | Data |
---|---|---|
b7449926 | 1 | // run-pass |
0bf4aa26 | 2 | #![allow(dead_code)] |
1a4d82fc | 3 | use std::cmp::PartialEq; |
223e47cc | 4 | |
1a4d82fc | 5 | trait MyNum : PartialEq { } |
223e47cc | 6 | |
85aaf69f | 7 | #[derive(Debug)] |
c34b1796 | 8 | struct MyInt { val: isize } |
223e47cc | 9 | |
1a4d82fc | 10 | impl PartialEq for MyInt { |
223e47cc LB |
11 | fn eq(&self, other: &MyInt) -> bool { self.val == other.val } |
12 | fn ne(&self, other: &MyInt) -> bool { !self.eq(other) } | |
13 | } | |
14 | ||
1a4d82fc | 15 | impl MyNum for MyInt {} |
223e47cc LB |
16 | |
17 | fn f<T:MyNum>(x: T, y: T) -> bool { | |
18 | return x == y; | |
19 | } | |
20 | ||
c34b1796 | 21 | fn mi(v: isize) -> MyInt { MyInt { val: v } } |
223e47cc LB |
22 | |
23 | pub fn main() { | |
24 | let (x, y, z) = (mi(3), mi(5), mi(3)); | |
25 | assert!(x != y); | |
970d7e83 | 26 | assert_eq!(x, z); |
223e47cc | 27 | } |