From 31fa86511c0b7ccfc3d9977730593d0fd442f6fe Mon Sep 17 00:00:00 2001 From: David Creswick Date: Thu, 29 Aug 2013 13:22:04 -0500 Subject: [PATCH 1/2] drop some redundant Ord method implementations --- src/libextra/json.rs | 5 +---- src/libextra/num/rational.rs | 2 +- src/libextra/semver.rs | 14 +------------- 3 files changed, 3 insertions(+), 18 deletions(-) diff --git a/src/libextra/json.rs b/src/libextra/json.rs index a13836d87bd74..911d53da9092c 100644 --- a/src/libextra/json.rs +++ b/src/libextra/json.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -1164,9 +1164,6 @@ impl Ord for Json { } } } - fn le(&self, other: &Json) -> bool { !(*other).lt(&(*self)) } - fn ge(&self, other: &Json) -> bool { !(*self).lt(other) } - fn gt(&self, other: &Json) -> bool { (*other).lt(&(*self)) } } /// A trait for converting values to JSON diff --git a/src/libextra/num/rational.rs b/src/libextra/num/rational.rs index 41e9a488bf8ae..3ef34b9cee9e5 100644 --- a/src/libextra/num/rational.rs +++ b/src/libextra/num/rational.rs @@ -107,7 +107,7 @@ macro_rules! cmp_impl { } cmp_impl!(impl Eq, eq, ne) cmp_impl!(impl TotalEq, equals) -cmp_impl!(impl Ord, lt, gt, le, ge) +cmp_impl!(impl Ord, lt) cmp_impl!(impl TotalOrd, cmp -> cmp::Ordering) impl Orderable for Ratio { diff --git a/src/libextra/semver.rs b/src/libextra/semver.rs index b0f89e219d8d8..8f7c6a03d1a73 100644 --- a/src/libextra/semver.rs +++ b/src/libextra/semver.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -37,18 +37,6 @@ impl cmp::Ord for Identifier { (&AlphaNumeric(_), _) => false } } - #[inline] - fn le(&self, other: &Identifier) -> bool { - ! (other < self) - } - #[inline] - fn gt(&self, other: &Identifier) -> bool { - other < self - } - #[inline] - fn ge(&self, other: &Identifier) -> bool { - ! (self < other) - } } impl ToStr for Identifier { From b9601c48a525dcdc569052e65c3c6b93833f3011 Mon Sep 17 00:00:00 2001 From: David Creswick Date: Thu, 29 Aug 2013 17:52:22 -0500 Subject: [PATCH 2/2] partial revert of 31fa865 Ratio is generic and so might contain a non-total orderable type. It should not use the default Ord implementation. --- src/libextra/num/rational.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libextra/num/rational.rs b/src/libextra/num/rational.rs index 3ef34b9cee9e5..41e9a488bf8ae 100644 --- a/src/libextra/num/rational.rs +++ b/src/libextra/num/rational.rs @@ -107,7 +107,7 @@ macro_rules! cmp_impl { } cmp_impl!(impl Eq, eq, ne) cmp_impl!(impl TotalEq, equals) -cmp_impl!(impl Ord, lt) +cmp_impl!(impl Ord, lt, gt, le, ge) cmp_impl!(impl TotalOrd, cmp -> cmp::Ordering) impl Orderable for Ratio {