From 3829ac2a52f12b08501cb25d82de32f39fbe801e Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Sat, 22 Mar 2014 16:30:45 -0400 Subject: use TotalEq for HashMap Closes #5283 --- src/libstd/fmt/parse.rs | 4 ++-- src/libstd/path/posix.rs | 4 +++- src/libstd/path/windows.rs | 4 +++- src/libstd/ptr.rs | 8 +++++++- src/libstd/rc.rs | 9 ++++++++- 5 files changed, 23 insertions(+), 6 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/fmt/parse.rs b/src/libstd/fmt/parse.rs index 948f85ca1c2..67088e6f4f8 100644 --- a/src/libstd/fmt/parse.rs +++ b/src/libstd/fmt/parse.rs @@ -121,7 +121,7 @@ pub enum Method<'a> { } /// A selector for what pluralization a plural method should take -#[deriving(Eq, Hash)] +#[deriving(Eq, TotalEq, Hash)] pub enum PluralSelector { /// One of the plural keywords should be used Keyword(PluralKeyword), @@ -143,7 +143,7 @@ pub struct PluralArm<'a> { /// specially placed in the `Plural` variant of `Method` /// /// http://www.icu-project.org/apiref/icu4c/classicu_1_1PluralRules.html -#[deriving(Eq, Hash)] +#[deriving(Eq, TotalEq, Hash)] #[allow(missing_doc)] pub enum PluralKeyword { Zero, One, Two, Few, Many diff --git a/src/libstd/path/posix.rs b/src/libstd/path/posix.rs index f654f59266a..512b20ebf4c 100644 --- a/src/libstd/path/posix.rs +++ b/src/libstd/path/posix.rs @@ -13,7 +13,7 @@ use container::Container; use c_str::{CString, ToCStr}; use clone::Clone; -use cmp::Eq; +use cmp::{Eq, TotalEq}; use from_str::FromStr; use io::Writer; use iter::{AdditiveIterator, Extendable, Iterator, Map}; @@ -69,6 +69,8 @@ impl Eq for Path { } } +impl TotalEq for Path {} + impl FromStr for Path { fn from_str(s: &str) -> Option { Path::new_opt(s) diff --git a/src/libstd/path/windows.rs b/src/libstd/path/windows.rs index dba8af4128b..81da2f50f8d 100644 --- a/src/libstd/path/windows.rs +++ b/src/libstd/path/windows.rs @@ -15,7 +15,7 @@ use c_str::{CString, ToCStr}; use cast; use clone::Clone; use container::Container; -use cmp::Eq; +use cmp::{Eq, TotalEq}; use from_str::FromStr; use io::Writer; use iter::{AdditiveIterator, DoubleEndedIterator, Extendable, Rev, Iterator, Map}; @@ -93,6 +93,8 @@ impl Eq for Path { } } +impl TotalEq for Path {} + impl FromStr for Path { fn from_str(s: &str) -> Option { Path::new_opt(s) diff --git a/src/libstd/ptr.rs b/src/libstd/ptr.rs index 179100255c4..504c613bf4c 100644 --- a/src/libstd/ptr.rs +++ b/src/libstd/ptr.rs @@ -19,7 +19,7 @@ use mem; use option::{Option, Some, None}; use intrinsics; -#[cfg(not(test))] use cmp::{Eq, Ord}; +#[cfg(not(test))] use cmp::{Eq, TotalEq, Ord}; /// Return the offset of the first null pointer in `buf`. #[inline] @@ -272,6 +272,9 @@ impl Eq for *T { fn ne(&self, other: &*T) -> bool { !self.eq(other) } } +#[cfg(not(test))] +impl TotalEq for *T {} + #[cfg(not(test))] impl Eq for *mut T { #[inline] @@ -282,6 +285,9 @@ impl Eq for *mut T { fn ne(&self, other: &*mut T) -> bool { !self.eq(other) } } +#[cfg(not(test))] +impl TotalEq for *mut T {} + // Equivalence for pointers #[cfg(not(test))] impl Equiv<*mut T> for *T { diff --git a/src/libstd/rc.rs b/src/libstd/rc.rs index 8dd06cb9232..d26038f508f 100644 --- a/src/libstd/rc.rs +++ b/src/libstd/rc.rs @@ -26,7 +26,7 @@ pointers, and then storing the parent pointers as `Weak` pointers. use cast::transmute; use cell::Cell; use clone::Clone; -use cmp::{Eq, Ord}; +use cmp::{Eq, Ord, TotalEq, TotalOrd, Ordering}; use kinds::marker; use ops::{Deref, Drop}; use option::{Option, Some, None}; @@ -127,6 +127,8 @@ impl Eq for Rc { fn ne(&self, other: &Rc) -> bool { **self != **other } } +impl TotalEq for Rc {} + impl Ord for Rc { #[inline(always)] fn lt(&self, other: &Rc) -> bool { **self < **other } @@ -141,6 +143,11 @@ impl Ord for Rc { fn ge(&self, other: &Rc) -> bool { **self >= **other } } +impl TotalOrd for Rc { + #[inline] + fn cmp(&self, other: &Rc) -> Ordering { (**self).cmp(&**other) } +} + /// Weak reference to a reference-counted box #[unsafe_no_drop_flag] pub struct Weak { -- cgit 1.4.1-3-g733a5