Skip to content

Commit

Permalink
Reuse cmp in totally ordered types
Browse files Browse the repository at this point in the history
Instead of manually defining it, `partial_cmp` can simply wrap the
result of `cmp` for totally ordered types.
  • Loading branch information
ranma42 committed Sep 16, 2015
1 parent d04b8b5 commit bf9254a
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/libcore/cmp.rs
Expand Up @@ -471,9 +471,7 @@ mod impls {
impl PartialOrd for $t {
#[inline]
fn partial_cmp(&self, other: &$t) -> Option<Ordering> {
if *self == *other { Some(Equal) }
else if *self < *other { Some(Less) }
else { Some(Greater) }
Some(self.cmp(other))
}
#[inline]
fn lt(&self, other: &$t) -> bool { (*self) < (*other) }
Expand Down

0 comments on commit bf9254a

Please sign in to comment.