about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorCorey Farwell <coreyf@rwell.org>2017-03-31 11:43:38 -0400
committerGitHub <noreply@github.com>2017-03-31 11:43:38 -0400
commitd36b24d8bfac4b66e13c4c540c803c8697cedd45 (patch)
tree7eb9107932ab3c9aa26242652b33af7a0f05842b /src/libcore
parentc650ed8ee7704732664befde0f6e4d471eb626db (diff)
parent6fda0fe891fd85f5cde89fe672d5796f15269898 (diff)
downloadrust-d36b24d8bfac4b66e13c4c540c803c8697cedd45.tar.gz
rust-d36b24d8bfac4b66e13c4c540c803c8697cedd45.zip
Rollup merge of #40929 - bluss:full-reverse, r=alexcrichton
Implement all PartialOrd methods for Reverse

When making a forwarding wrapper we must in general forward all methods,
so that we use the type's own `lt` for example instead of the default.

Example important case: f32's partial_cmp does several operations but
its lt is a primitive.

Follow up on #40720
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/cmp.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs
index dc2398b22ac..74ded948b18 100644
--- a/src/libcore/cmp.rs
+++ b/src/libcore/cmp.rs
@@ -347,6 +347,15 @@ impl<T: PartialOrd> PartialOrd for Reverse<T> {
     fn partial_cmp(&self, other: &Reverse<T>) -> Option<Ordering> {
         other.0.partial_cmp(&self.0)
     }
+
+    #[inline]
+    fn lt(&self, other: &Self) -> bool { other.0 < self.0 }
+    #[inline]
+    fn le(&self, other: &Self) -> bool { other.0 <= self.0 }
+    #[inline]
+    fn ge(&self, other: &Self) -> bool { other.0 >= self.0 }
+    #[inline]
+    fn gt(&self, other: &Self) -> bool { other.0 > self.0 }
 }
 
 #[unstable(feature = "reverse_cmp_key", issue = "40893")]