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 unique pointer types
13 #[cfg(not(test))] use cmp::*;
15 /// A value that represents the global exchange heap. This is the default
16 /// place that the `box` keyword allocates into when no place is supplied.
18 /// The following two examples are equivalent:
20 /// let foo = box(HEAP) Bar::new(...);
21 /// let foo = box Bar::new(...);
22 #[lang="exchange_heap"]
24 pub static HEAP: () = ();
27 pub static HEAP: () = ();
29 /// A type that represents a uniquely-owned value.
32 pub struct Box<T>(*T);
35 pub struct Box<T>(*T);
38 impl<T:Eq> Eq for ~T {
40 fn eq(&self, other: &~T) -> bool { *(*self) == *(*other) }
42 fn ne(&self, other: &~T) -> bool { *(*self) != *(*other) }
46 impl<T:Ord> Ord for ~T {
48 fn lt(&self, other: &~T) -> bool { *(*self) < *(*other) }
50 fn le(&self, other: &~T) -> bool { *(*self) <= *(*other) }
52 fn ge(&self, other: &~T) -> bool { *(*self) >= *(*other) }
54 fn gt(&self, other: &~T) -> bool { *(*self) > *(*other) }
58 impl<T: TotalOrd> TotalOrd for ~T {
60 fn cmp(&self, other: &~T) -> Ordering { (**self).cmp(*other) }
64 impl<T: TotalEq> TotalEq for ~T {}