1 // 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.
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.
11 //! Operations on managed box types
13 #[cfg(not(test))] use cmp::*;
15 /// Determine if two shared boxes point to the same object
17 pub fn ptr_eq<T>(a: @T, b: @T) -> bool {
18 &*a as *T == &*b as *T
22 impl<T:Eq> Eq for @T {
24 fn eq(&self, other: &@T) -> bool { *(*self) == *(*other) }
26 fn ne(&self, other: &@T) -> bool { *(*self) != *(*other) }
30 impl<T:Ord> Ord for @T {
32 fn lt(&self, other: &@T) -> bool { *(*self) < *(*other) }
34 fn le(&self, other: &@T) -> bool { *(*self) <= *(*other) }
36 fn ge(&self, other: &@T) -> bool { *(*self) >= *(*other) }
38 fn gt(&self, other: &@T) -> bool { *(*self) > *(*other) }
42 impl<T: TotalOrd> TotalOrd for @T {
44 fn cmp(&self, other: &@T) -> Ordering { (**self).cmp(*other) }
48 impl<T: TotalEq> TotalEq for @T {}
54 assert!((ptr_eq::<int>(x, x)));
55 assert!((ptr_eq::<int>(y, y)));
56 assert!((!ptr_eq::<int>(x, y)));
57 assert!((!ptr_eq::<int>(y, x)));