1
Fork 0

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:
Andrea Canciani 2015-09-16 15:25:51 +02:00
parent d04b8b5818
commit bf9254a75e

View file

@ -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) }