Skip to content

Commit bf9254a

Browse files
committed
Reuse cmp in totally ordered types
Instead of manually defining it, `partial_cmp` can simply wrap the result of `cmp` for totally ordered types.
1 parent d04b8b5 commit bf9254a

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/libcore/cmp.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -471,9 +471,7 @@ mod impls {
471471
impl PartialOrd for $t {
472472
#[inline]
473473
fn partial_cmp(&self, other: &$t) -> Option<Ordering> {
474-
if *self == *other { Some(Equal) }
475-
else if *self < *other { Some(Less) }
476-
else { Some(Greater) }
474+
Some(self.cmp(other))
477475
}
478476
#[inline]
479477
fn lt(&self, other: &$t) -> bool { (*self) < (*other) }

0 commit comments

Comments
 (0)