]>
Commit | Line | Data |
---|---|---|
c34b1796 | 1 | pub struct Something { pub x: isize } |
970d7e83 LB |
2 | |
3 | pub trait A { | |
c34b1796 AL |
4 | fn f(&self) -> isize; |
5 | fn g(&self) -> isize { 10 } | |
6 | fn h(&self) -> isize { 11 } | |
7 | fn lurr(x: &Self, y: &Self) -> isize { x.g() + y.h() } | |
970d7e83 LB |
8 | } |
9 | ||
10 | ||
c34b1796 AL |
11 | impl A for isize { |
12 | fn f(&self) -> isize { 10 } | |
970d7e83 LB |
13 | } |
14 | ||
1a4d82fc | 15 | impl A for Something { |
c34b1796 | 16 | fn f(&self) -> isize { 10 } |
1a4d82fc JJ |
17 | } |
18 | ||
19 | pub trait B<T> { | |
970d7e83 | 20 | fn thing<U>(&self, x: T, y: U) -> (T, U) { (x, y) } |
1a4d82fc | 21 | fn staticthing<U>(_z: &Self, x: T, y: U) -> (T, U) { (x, y) } |
970d7e83 LB |
22 | } |
23 | ||
c34b1796 | 24 | impl<T> B<T> for isize { } |
1a4d82fc | 25 | impl B<f64> for bool { } |
970d7e83 LB |
26 | |
27 | ||
28 | ||
29 | pub trait TestEquality { | |
30 | fn test_eq(&self, rhs: &Self) -> bool; | |
31 | fn test_neq(&self, rhs: &Self) -> bool { | |
32 | !self.test_eq(rhs) | |
33 | } | |
34 | } | |
35 | ||
c34b1796 AL |
36 | impl TestEquality for isize { |
37 | fn test_eq(&self, rhs: &isize) -> bool { | |
970d7e83 LB |
38 | *self == *rhs |
39 | } | |
40 | } |