Reuse cmp in totally ordered types
Instead of manually defining it, `partial_cmp` can simply wrap the result of `cmp` for totally ordered types.
This commit is contained in:
parent
d04b8b5818
commit
bf9254a75e
1 changed files with 1 additions and 3 deletions
|
@ -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) }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue