about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-06-30 05:36:25 +0000
committerbors <bors@rust-lang.org>2014-06-30 05:36:25 +0000
commite1683f50c00297e9908ae028fa1d41b9a52a6f6f (patch)
treee1f34ea8fa1e5c887ed724e41a029cab323ad455 /src/liballoc
parente25eb6b223d86047dc807a167f3dd4bf492bbf41 (diff)
parent55cae0a094bbdcd0e9d5e697ce4f38cbd783bbc7 (diff)
downloadrust-e1683f50c00297e9908ae028fa1d41b9a52a6f6f.tar.gz
rust-e1683f50c00297e9908ae028fa1d41b9a52a6f6f.zip
auto merge of #15030 : sfackler/rust/partial-cmp, r=huonw
I ended up altering the semantics of Json's PartialOrd implementation.
It used to be the case that Null < Null, but I can't think of any reason
for an ordering other than the default one so I just switched it over to
using the derived implementation.

This also fixes broken `PartialOrd` implementations for `Vec` and
`TreeMap`.

# Note
This isn't ready to merge yet since libcore tests are broken as you end up with 2 versions of `Option`. The rest should be reviewable though.

RFC: 0028-partial-cmp
Diffstat (limited to 'src/liballoc')
-rw-r--r--src/liballoc/owned.rs5
-rw-r--r--src/liballoc/rc.rs5
2 files changed, 10 insertions, 0 deletions
diff --git a/src/liballoc/owned.rs b/src/liballoc/owned.rs
index 33afa806f4e..addec396bbe 100644
--- a/src/liballoc/owned.rs
+++ b/src/liballoc/owned.rs
@@ -18,6 +18,7 @@ use core::fmt;
 use core::intrinsics;
 use core::kinds::Send;
 use core::mem;
+use core::option::Option;
 use core::raw::TraitObject;
 use core::result::{Ok, Err, Result};
 
@@ -65,6 +66,10 @@ impl<T:PartialEq> PartialEq for Box<T> {
 }
 impl<T:PartialOrd> PartialOrd for Box<T> {
     #[inline]
+    fn partial_cmp(&self, other: &Box<T>) -> Option<Ordering> {
+        (**self).partial_cmp(*other)
+    }
+    #[inline]
     fn lt(&self, other: &Box<T>) -> bool { *(*self) < *(*other) }
     #[inline]
     fn le(&self, other: &Box<T>) -> bool { *(*self) <= *(*other) }
diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs
index e3127030842..83cc4a0b662 100644
--- a/src/liballoc/rc.rs
+++ b/src/liballoc/rc.rs
@@ -171,6 +171,11 @@ impl<T: Eq> Eq for Rc<T> {}
 
 impl<T: PartialOrd> PartialOrd for Rc<T> {
     #[inline(always)]
+    fn partial_cmp(&self, other: &Rc<T>) -> Option<Ordering> {
+        (**self).partial_cmp(&**other)
+    }
+
+    #[inline(always)]
     fn lt(&self, other: &Rc<T>) -> bool { **self < **other }
 
     #[inline(always)]