about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorAndrea Canciani <ranma42@gmail.com>2015-09-16 15:25:51 +0200
committerAndrea Canciani <ranma42@gmail.com>2015-09-16 15:25:51 +0200
commitbf9254a75e06f61ecd837e2f90ed0afc22ffdede (patch)
tree27d200fc983da5335683e42a80b08191e4137e55 /src/libcore
parentd04b8b5818819470457fc00f87176b273d756980 (diff)
downloadrust-bf9254a75e06f61ecd837e2f90ed0afc22ffdede.tar.gz
rust-bf9254a75e06f61ecd837e2f90ed0afc22ffdede.zip
Reuse cmp in totally ordered types
Instead of manually defining it, `partial_cmp` can simply wrap the
result of `cmp` for totally ordered types.
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/cmp.rs4
1 files changed, 1 insertions, 3 deletions
diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs
index dc550fc2173..3344d7ea5d7 100644
--- a/src/libcore/cmp.rs
+++ b/src/libcore/cmp.rs
@@ -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) }