diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 5c61a1ed10368..edd5f989797b5 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -93,7 +93,7 @@ use intrinsics; use option::Option; use option::Option::{Some, None}; -use cmp::{PartialEq, Eq, PartialOrd, Equiv}; +use cmp::{PartialEq, Eq, Ord, PartialOrd, Equiv}; use cmp::Ordering; use cmp::Ordering::{Less, Equal, Greater}; @@ -388,17 +388,24 @@ mod externfnpointers { } // Comparison for pointers -impl PartialOrd for *const T { +impl Ord for *const T { #[inline] - fn partial_cmp(&self, other: &*const T) -> Option { + fn cmp(&self, other: &*const T) -> Ordering { if self < other { - Some(Less) + Less } else if self == other { - Some(Equal) + Equal } else { - Some(Greater) + Greater } } +} + +impl PartialOrd for *const T { + #[inline] + fn partial_cmp(&self, other: &*const T) -> Option { + Some(self.cmp(other)) + } #[inline] fn lt(&self, other: &*const T) -> bool { *self < *other } @@ -413,17 +420,24 @@ impl PartialOrd for *const T { fn ge(&self, other: &*const T) -> bool { *self >= *other } } -impl PartialOrd for *mut T { +impl Ord for *mut T { #[inline] - fn partial_cmp(&self, other: &*mut T) -> Option { + fn cmp(&self, other: &*mut T) -> Ordering { if self < other { - Some(Less) + Less } else if self == other { - Some(Equal) + Equal } else { - Some(Greater) + Greater } } +} + +impl PartialOrd for *mut T { + #[inline] + fn partial_cmp(&self, other: &*mut T) -> Option { + Some(self.cmp(other)) + } #[inline] fn lt(&self, other: &*mut T) -> bool { *self < *other }