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:
@@ -471,9 +471,7 @@ mod impls {
|
|||||||
impl PartialOrd for $t {
|
impl PartialOrd for $t {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn partial_cmp(&self, other: &$t) -> Option<Ordering> {
|
fn partial_cmp(&self, other: &$t) -> Option<Ordering> {
|
||||||
if *self == *other { Some(Equal) }
|
Some(self.cmp(other))
|
||||||
else if *self < *other { Some(Less) }
|
|
||||||
else { Some(Greater) }
|
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
fn lt(&self, other: &$t) -> bool { (*self) < (*other) }
|
fn lt(&self, other: &$t) -> bool { (*self) < (*other) }
|
||||||
|
|||||||
Reference in New Issue
Block a user