about summary refs log tree commit diff
path: root/src/libcore/ptr.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-12-15 15:33:11 +0000
committerbors <bors@rust-lang.org>2014-12-15 15:33:11 +0000
commit1b97cd338b5d425b24e821e815d84005e38b390a (patch)
tree28aadb0b5d2e8982efd923532534f6c65d1583fa /src/libcore/ptr.rs
parentef0bc464af110d24d4663fbe51eca3646a897308 (diff)
parent1cb7e9fc638e1addbc3645f202ea89a42662812b (diff)
auto merge of #19785 : brson/rust/rollup, r=brson
Diffstat (limited to 'src/libcore/ptr.rs')
-rw-r--r--src/libcore/ptr.rs36
1 files changed, 25 insertions, 11 deletions
diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs
index 5c61a1ed103..edd5f989797 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<T> PartialOrd for *const T {
+impl<T> Ord for *const T {
     #[inline]
-    fn partial_cmp(&self, other: &*const T) -> Option<Ordering> {
+    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<T> PartialOrd for *const T {
+    #[inline]
+    fn partial_cmp(&self, other: &*const T) -> Option<Ordering> {
+        Some(self.cmp(other))
+    }
 
     #[inline]
     fn lt(&self, other: &*const T) -> bool { *self < *other }
@@ -413,17 +420,24 @@ impl<T> PartialOrd for *const T {
     fn ge(&self, other: &*const T) -> bool { *self >= *other }
 }
 
-impl<T> PartialOrd for *mut T {
+impl<T> Ord for *mut T {
     #[inline]
-    fn partial_cmp(&self, other: &*mut T) -> Option<Ordering> {
+    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<T> PartialOrd for *mut T {
+    #[inline]
+    fn partial_cmp(&self, other: &*mut T) -> Option<Ordering> {
+        Some(self.cmp(other))
+    }
 
     #[inline]
     fn lt(&self, other: &*mut T) -> bool { *self < *other }