mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-16 13:05:18 +03:00
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:
+1
-3
@@ -471,9 +471,7 @@ macro_rules! ord_impl {
|
||||
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) }
|
||||
|
||||
Reference in New Issue
Block a user