Skip to content

Commit d36b24d

Browse files
authored
Rollup merge of rust-lang#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 rust-lang#40720
2 parents c650ed8 + 6fda0fe commit d36b24d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/libcore/cmp.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,15 @@ impl<T: PartialOrd> PartialOrd for Reverse<T> {
347347
fn partial_cmp(&self, other: &Reverse<T>) -> Option<Ordering> {
348348
other.0.partial_cmp(&self.0)
349349
}
350+
351+
#[inline]
352+
fn lt(&self, other: &Self) -> bool { other.0 < self.0 }
353+
#[inline]
354+
fn le(&self, other: &Self) -> bool { other.0 <= self.0 }
355+
#[inline]
356+
fn ge(&self, other: &Self) -> bool { other.0 >= self.0 }
357+
#[inline]
358+
fn gt(&self, other: &Self) -> bool { other.0 > self.0 }
350359
}
351360

352361
#[unstable(feature = "reverse_cmp_key", issue = "40893")]

0 commit comments

Comments
 (0)