From 6fda0fe891fd85f5cde89fe672d5796f15269898 Mon Sep 17 00:00:00 2001 From: Ulrik Sverdrup Date: Thu, 30 Mar 2017 17:25:36 +0200 Subject: [PATCH] cmp: 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. --- src/libcore/cmp.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index dc2398b22acec..74ded948b18e7 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -347,6 +347,15 @@ impl PartialOrd for Reverse { fn partial_cmp(&self, other: &Reverse) -> Option { 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")]