From e7b41caba8b968450717b487087b5a2cdc10461a Mon Sep 17 00:00:00 2001 From: nham Date: Sun, 27 Jul 2014 14:41:33 -0400 Subject: [PATCH] Implement Hash for tuples of up to arity 12. Also change the style to be consistent with core::tuple --- src/libcollections/hash/mod.rs | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/libcollections/hash/mod.rs b/src/libcollections/hash/mod.rs index 357383207150e..6f8b63953e2b4 100644 --- a/src/libcollections/hash/mod.rs +++ b/src/libcollections/hash/mod.rs @@ -155,29 +155,36 @@ macro_rules! impl_hash_tuple( } ); - ($A:ident $($B:ident)*) => ( - impl< - S: Writer, - $A: Hash $(, $B: Hash)* - > Hash for ($A, $($B),*) { + ( $($name:ident)+) => ( + impl),*> Hash for ($($name,)*) { + #[allow(uppercase_variables)] #[inline] fn hash(&self, state: &mut S) { match *self { - (ref $A, $(ref $B),*) => { - $A.hash(state); + ($(ref $name,)*) => { $( - $B.hash(state); + $name.hash(state); )* } } } } - - impl_hash_tuple!($($B)*) ); ) -impl_hash_tuple!(a0 a1 a2 a3 a4 a5 a6 a7) +impl_hash_tuple!() +impl_hash_tuple!(A) +impl_hash_tuple!(A B) +impl_hash_tuple!(A B C) +impl_hash_tuple!(A B C D) +impl_hash_tuple!(A B C D E) +impl_hash_tuple!(A B C D E F) +impl_hash_tuple!(A B C D E F G) +impl_hash_tuple!(A B C D E F G H) +impl_hash_tuple!(A B C D E F G H I) +impl_hash_tuple!(A B C D E F G H I J) +impl_hash_tuple!(A B C D E F G H I J K) +impl_hash_tuple!(A B C D E F G H I J K L) impl<'a, S: Writer, T: Hash> Hash for &'a [T] { #[inline]