diff options
| author | Andrea Canciani <ranma42@gmail.com> | 2015-09-16 15:25:51 +0200 |
|---|---|---|
| committer | Andrea Canciani <ranma42@gmail.com> | 2015-09-16 15:25:51 +0200 |
| commit | bf9254a75e06f61ecd837e2f90ed0afc22ffdede (patch) | |
| tree | 27d200fc983da5335683e42a80b08191e4137e55 /src/libcore | |
| parent | d04b8b5818819470457fc00f87176b273d756980 (diff) | |
| download | rust-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.rs | 4 |
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) } |
