|
1 |
| -// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT |
| 1 | +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT |
2 | 2 | // file at the top-level directory of this distribution and at
|
3 | 3 | // http://rust-lang.org/COPYRIGHT.
|
4 | 4 | //
|
@@ -217,6 +217,29 @@ mod impls {
|
217 | 217 | }
|
218 | 218 | impl<'a, T: TotalEq> TotalEq for &'a T {}
|
219 | 219 |
|
| 220 | + // &mut pointers |
| 221 | + impl<'a, T: Eq> Eq for &'a mut T { |
| 222 | + #[inline] |
| 223 | + fn eq(&self, other: &&'a mut T) -> bool { **self == *(*other) } |
| 224 | + #[inline] |
| 225 | + fn ne(&self, other: &&'a mut T) -> bool { **self != *(*other) } |
| 226 | + } |
| 227 | + impl<'a, T: Ord> Ord for &'a mut T { |
| 228 | + #[inline] |
| 229 | + fn lt(&self, other: &&'a mut T) -> bool { **self < **other } |
| 230 | + #[inline] |
| 231 | + fn le(&self, other: &&'a mut T) -> bool { **self <= **other } |
| 232 | + #[inline] |
| 233 | + fn ge(&self, other: &&'a mut T) -> bool { **self >= **other } |
| 234 | + #[inline] |
| 235 | + fn gt(&self, other: &&'a mut T) -> bool { **self > **other } |
| 236 | + } |
| 237 | + impl<'a, T: TotalOrd> TotalOrd for &'a mut T { |
| 238 | + #[inline] |
| 239 | + fn cmp(&self, other: &&'a mut T) -> Ordering { (**self).cmp(*other) } |
| 240 | + } |
| 241 | + impl<'a, T: TotalEq> TotalEq for &'a mut T {} |
| 242 | + |
220 | 243 | // @ pointers
|
221 | 244 | impl<T:Eq> Eq for @T {
|
222 | 245 | #[inline]
|
@@ -254,6 +277,15 @@ mod test {
|
254 | 277 | assert_eq!(12u.cmp(-5), Greater);
|
255 | 278 | }
|
256 | 279 |
|
| 280 | + #[test] |
| 281 | + fn test_mut_int_totalord() { |
| 282 | + assert_eq!((&mut 5u).cmp(&10), Less); |
| 283 | + assert_eq!((&mut 10u).cmp(&5), Greater); |
| 284 | + assert_eq!((&mut 5u).cmp(&5), Equal); |
| 285 | + assert_eq!((&mut -5u).cmp(&12), Less); |
| 286 | + assert_eq!((&mut 12u).cmp(-5), Greater); |
| 287 | + } |
| 288 | + |
257 | 289 | #[test]
|
258 | 290 | fn test_ordering_order() {
|
259 | 291 | assert!(Less < Equal);
|
|
0 commit comments