Skip to content

Commit e7b41ca

Browse files
committed
Implement Hash for tuples of up to arity 12. Also change the style to be consistent with core::tuple
1 parent e0d10bb commit e7b41ca

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

src/libcollections/hash/mod.rs

+18-11
Original file line numberDiff line numberDiff line change
@@ -155,29 +155,36 @@ macro_rules! impl_hash_tuple(
155155
}
156156
);
157157

158-
($A:ident $($B:ident)*) => (
159-
impl<
160-
S: Writer,
161-
$A: Hash<S> $(, $B: Hash<S>)*
162-
> Hash<S> for ($A, $($B),*) {
158+
( $($name:ident)+) => (
159+
impl<S: Writer, $($name: Hash<S>),*> Hash<S> for ($($name,)*) {
160+
#[allow(uppercase_variables)]
163161
#[inline]
164162
fn hash(&self, state: &mut S) {
165163
match *self {
166-
(ref $A, $(ref $B),*) => {
167-
$A.hash(state);
164+
($(ref $name,)*) => {
168165
$(
169-
$B.hash(state);
166+
$name.hash(state);
170167
)*
171168
}
172169
}
173170
}
174171
}
175-
176-
impl_hash_tuple!($($B)*)
177172
);
178173
)
179174

180-
impl_hash_tuple!(a0 a1 a2 a3 a4 a5 a6 a7)
175+
impl_hash_tuple!()
176+
impl_hash_tuple!(A)
177+
impl_hash_tuple!(A B)
178+
impl_hash_tuple!(A B C)
179+
impl_hash_tuple!(A B C D)
180+
impl_hash_tuple!(A B C D E)
181+
impl_hash_tuple!(A B C D E F)
182+
impl_hash_tuple!(A B C D E F G)
183+
impl_hash_tuple!(A B C D E F G H)
184+
impl_hash_tuple!(A B C D E F G H I)
185+
impl_hash_tuple!(A B C D E F G H I J)
186+
impl_hash_tuple!(A B C D E F G H I J K)
187+
impl_hash_tuple!(A B C D E F G H I J K L)
181188

182189
impl<'a, S: Writer, T: Hash<S>> Hash<S> for &'a [T] {
183190
#[inline]

0 commit comments

Comments
 (0)