std: implement Total{Ord,Eq} for pointers.
This commit is contained in:
@@ -58,3 +58,15 @@ impl<'self, T: Ord> Ord for &'self T {
|
|||||||
*(*self) > *(*other)
|
*(*self) > *(*other)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(test))]
|
||||||
|
impl<'self, T: TotalOrd> TotalOrd for &'self T {
|
||||||
|
#[inline]
|
||||||
|
fn cmp(&self, other: & &'self T) -> Ordering { (**self).cmp(*other) }
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(test))]
|
||||||
|
impl<'self, T: TotalEq> TotalEq for &'self T {
|
||||||
|
#[inline]
|
||||||
|
fn equals(&self, other: & &'self T) -> bool { (**self).equals(*other) }
|
||||||
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
use ptr::to_unsafe_ptr;
|
use ptr::to_unsafe_ptr;
|
||||||
|
|
||||||
#[cfg(not(test))] use cmp::{Eq, Ord};
|
#[cfg(not(test))] use cmp::*;
|
||||||
|
|
||||||
pub static RC_MANAGED_UNIQUE : uint = (-2) as uint;
|
pub static RC_MANAGED_UNIQUE : uint = (-2) as uint;
|
||||||
pub static RC_IMMORTAL : uint = 0x77777777;
|
pub static RC_IMMORTAL : uint = 0x77777777;
|
||||||
@@ -71,6 +71,29 @@ impl<T:Ord> Ord for @mut T {
|
|||||||
fn gt(&self, other: &@mut T) -> bool { *(*self) > *(*other) }
|
fn gt(&self, other: &@mut T) -> bool { *(*self) > *(*other) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(test))]
|
||||||
|
impl<T: TotalOrd> TotalOrd for @T {
|
||||||
|
#[inline]
|
||||||
|
fn cmp(&self, other: &@T) -> Ordering { (**self).cmp(*other) }
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(test))]
|
||||||
|
impl<T: TotalOrd> TotalOrd for @mut T {
|
||||||
|
#[inline]
|
||||||
|
fn cmp(&self, other: &@mut T) -> Ordering { (**self).cmp(*other) }
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(test))]
|
||||||
|
impl<T: TotalEq> TotalEq for @T {
|
||||||
|
#[inline]
|
||||||
|
fn equals(&self, other: &@T) -> bool { (**self).equals(*other) }
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(test))]
|
||||||
|
impl<T: TotalEq> TotalEq for @mut T {
|
||||||
|
#[inline]
|
||||||
|
fn equals(&self, other: &@mut T) -> bool { (**self).equals(*other) }
|
||||||
|
}
|
||||||
#[test]
|
#[test]
|
||||||
fn test() {
|
fn test() {
|
||||||
let x = @3;
|
let x = @3;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
//! Operations on unique pointer types
|
//! Operations on unique pointer types
|
||||||
|
|
||||||
#[cfg(not(test))] use cmp::{Eq, Ord};
|
#[cfg(not(test))] use cmp::*;
|
||||||
|
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
impl<T:Eq> Eq for ~T {
|
impl<T:Eq> Eq for ~T {
|
||||||
@@ -31,3 +31,15 @@ impl<T:Ord> Ord for ~T {
|
|||||||
#[inline]
|
#[inline]
|
||||||
fn gt(&self, other: &~T) -> bool { *(*self) > *(*other) }
|
fn gt(&self, other: &~T) -> bool { *(*self) > *(*other) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(test))]
|
||||||
|
impl<T: TotalOrd> TotalOrd for ~T {
|
||||||
|
#[inline]
|
||||||
|
fn cmp(&self, other: &~T) -> Ordering { (**self).cmp(*other) }
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(test))]
|
||||||
|
impl<T: TotalEq> TotalEq for ~T {
|
||||||
|
#[inline]
|
||||||
|
fn equals(&self, other: &~T) -> bool { (**self).equals(*other) }
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user