diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-02-18 15:34:32 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-02-18 15:34:48 -0800 |
| commit | 2cdbd288ac0606902885434e1ccd8d8bde68913d (patch) | |
| tree | 9a7d37f7dd44424182797c76d49ba0ece99f9513 /src/libcore/hash | |
| parent | 365bd9a9e3b9dafa98e26982353fd28a6ca1efef (diff) | |
| parent | a99e698628cbd396c8100ef776d10ac61d911847 (diff) | |
| download | rust-2cdbd288ac0606902885434e1ccd8d8bde68913d.tar.gz rust-2cdbd288ac0606902885434e1ccd8d8bde68913d.zip | |
rollup merge of #22210: aturon/stab-final-borrow
Conflicts: src/libcollections/btree/map.rs src/libcollections/str.rs src/libcollections/vec.rs src/libcore/borrow.rs src/libcore/hash/mod.rs src/libstd/collections/hash/map.rs src/libstd/collections/hash/set.rs
Diffstat (limited to 'src/libcore/hash')
| -rw-r--r-- | src/libcore/hash/mod.rs | 118 |
1 files changed, 2 insertions, 116 deletions
diff --git a/src/libcore/hash/mod.rs b/src/libcore/hash/mod.rs index b9a5122dd9c..3d0c9761dda 100644 --- a/src/libcore/hash/mod.rs +++ b/src/libcore/hash/mod.rs @@ -58,8 +58,9 @@ #![stable(feature = "rust1", since = "1.0.0")] +use prelude::*; + use default::Default; -use marker::Sized; use mem; pub use self::sip::SipHasher; @@ -398,119 +399,4 @@ mod impls { } )*} } - - impl_write! { - (u8, write_u8), - (u16, write_u16), - (u32, write_u32), - (u64, write_u64), - (usize, write_usize), - (i8, write_i8), - (i16, write_i16), - (i32, write_i32), - (i64, write_i64), - (isize, write_isize), - } - - #[stable(feature = "rust1", since = "1.0.0")] - impl Hash for bool { - fn hash<H: Hasher>(&self, state: &mut H) { - state.write_u8(*self as u8) - } - } - - #[stable(feature = "rust1", since = "1.0.0")] - impl Hash for char { - fn hash<H: Hasher>(&self, state: &mut H) { - state.write_u32(*self as u32) - } - } - - #[stable(feature = "rust1", since = "1.0.0")] - impl Hash for str { - fn hash<H: Hasher>(&self, state: &mut H) { - state.write(self.as_bytes()); - state.write_u8(0xff) - } - } - - macro_rules! impl_hash_tuple { - () => ( - #[stable(feature = "rust1", since = "1.0.0")] - impl Hash for () { - fn hash<H: Hasher>(&self, _state: &mut H) {} - } - ); - - ( $($name:ident)+) => ( - #[stable(feature = "rust1", since = "1.0.0")] - impl<$($name: Hash),*> Hash for ($($name,)*) { - #[allow(non_snake_case)] - fn hash<S: Hasher>(&self, state: &mut S) { - let ($(ref $name,)*) = *self; - $($name.hash(state);)* - } - } - ); - } - - 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 } - - #[stable(feature = "rust1", since = "1.0.0")] - impl<T: Hash> Hash for [T] { - fn hash<H: Hasher>(&self, state: &mut H) { - self.len().hash(state); - Hash::hash_slice(self, state) - } - } - - - #[stable(feature = "rust1", since = "1.0.0")] - impl<'a, T: ?Sized + Hash> Hash for &'a T { - fn hash<H: Hasher>(&self, state: &mut H) { - (**self).hash(state); - } - } - - #[stable(feature = "rust1", since = "1.0.0")] - impl<'a, T: ?Sized + Hash> Hash for &'a mut T { - fn hash<H: Hasher>(&self, state: &mut H) { - (**self).hash(state); - } - } - - #[stable(feature = "rust1", since = "1.0.0")] - impl<T> Hash for *const T { - fn hash<H: Hasher>(&self, state: &mut H) { - state.write_usize(*self as usize) - } - } - - #[stable(feature = "rust1", since = "1.0.0")] - impl<T> Hash for *mut T { - fn hash<H: Hasher>(&self, state: &mut H) { - state.write_usize(*self as usize) - } - } - - #[stable(feature = "rust1", since = "1.0.0")] - impl<'a, T, B: ?Sized> Hash for Cow<'a, T, B> - where B: Hash + ToOwned<T> - { - fn hash<H: Hasher>(&self, state: &mut H) { - Hash::hash(&**self, state) - } - } } |
