# Trait core::hash::Hash 1.0.0 [−] [src]

    pub trait Hash {
        fn hash<H: Hasher>(&self, state: &mut H);

        fn hash_slice<H: Hasher>(data: &[Self], state: &mut H) where Self: Sized { ... }
    }

A hashable type.

The `H` type parameter is an abstract hash state that is used by the `Hash` to compute the hash.

If you are also implementing `Eq`, there is an additional property that is important:

    k1 == k2 -> hash(k1) == hash(k2)

In other words, if two keys are equal, their hashes should also be equal. `HashMap` and `HashSet` both rely on this behavior.

## Derivable

This trait can be used with `#[derive]` if all fields implement `Hash`. When `derive`d, the resulting hash will be the combination of the values from calling `.hash()` on each field.

## How can I implement `Hash`?

If you need more control over how a value is hashed, you need to implement the `Hash` trait:

    use std::hash::{Hash, Hasher};

    struct Person {
        id: u32,
        name: String,
        phone: u64,
    }

    impl Hash for Person {
        fn hash<H: Hasher>(&self, state: &mut H) {
            self.id.hash(state);
            self.phone.hash(state);
        }
    }Run

## Required Methods

### `fn hash<H: Hasher>(&self, state: &mut H)`

Feeds this value into the state given, updating the hasher as necessary.

## Provided Methods

### `fn hash_slice<H: Hasher>(data: &[Self], state: &mut H) where Self: Sized`
1.3.0

Feeds a slice of this type into the state provided.

## Implementors

- `impl<T: Hash> Hash for Wrapping<T>`
- `impl<T> Hash for Discriminant<T>`
- `impl<T: Hash + Zeroable> Hash for NonZero<T>`
- `impl<Ret> Hash for fn() -> Ret`
- `impl<Ret> Hash for extern fn() -> Ret`
- `impl<Ret> Hash for unsafe fn() -> Ret`
- `impl<Ret> Hash for unsafe extern fn() -> Ret`
- `impl<Ret, A> Hash for fn(_: A) -> Ret`
- `impl<Ret, A> Hash for extern fn(_: A) -> Ret`
- `impl<Ret, A> Hash for extern fn(_: A, ...) -> Ret`
- `impl<Ret, A> Hash for unsafe fn(_: A) -> Ret`
- `impl<Ret, A> Hash for unsafe extern fn(_: A) -> Ret`
- `impl<Ret, A> Hash for unsafe extern fn(_: A, ...) -> Ret`
- `impl<Ret, A, B> Hash for fn(_: A, _: B) -> Ret`
- `impl<Ret, A, B> Hash for extern fn(_: A, _: B) -> Ret`
- `impl<Ret, A, B> Hash for extern fn(_: A, _: B, ...) -> Ret`
- `impl<Ret, A, B> Hash for unsafe fn(_: A, _: B) -> Ret`
- `impl<Ret, A, B> Hash for unsafe extern fn(_: A, _: B) -> Ret`
- `impl<Ret, A, B> Hash for unsafe extern fn(_: A, _: B, ...) -> Ret`
- `impl<Ret, A, B, C> Hash for fn(_: A, _: B, _: C) -> Ret`
- `impl<Ret, A, B, C> Hash for extern fn(_: A, _: B, _: C) -> Ret`
- `impl<Ret, A, B, C> Hash for extern fn(_: A, _: B, _: C, ...) -> Ret`
- `impl<Ret, A, B, C> Hash for unsafe fn(_: A, _: B, _: C) -> Ret`
- `impl<Ret, A, B, C> Hash for unsafe extern fn(_: A, _: B, _: C) -> Ret`
- `impl<Ret, A, B, C> Hash for unsafe extern fn(_: A, _: B, _: C, ...) -> Ret`
- `impl<Ret, A, B, C, D> Hash for fn(_: A, _: B, _: C, _: D) -> Ret`
- `impl<Ret, A, B, C, D> Hash for extern fn(_: A, _: B, _: C, _: D) -> Ret`
- `impl<Ret, A, B, C, D> Hash for extern fn(_: A, _: B, _: C, _: D, ...) -> Ret`
- `impl<Ret, A, B, C, D> Hash for unsafe fn(_: A, _: B, _: C, _: D) -> Ret`
- `impl<Ret, A, B, C, D> Hash for unsafe extern fn(_: A, _: B, _: C, _: D) -> Ret`
- `impl<Ret, A, B, C, D> Hash for unsafe extern fn(_: A, _: B, _: C, _: D, ...) -> Ret`
- `impl<Ret, A, B, C, D, E> Hash for fn(_: A, _: B, _: C, _: D, _: E) -> Ret`
- `impl<Ret, A, B, C, D, E> Hash for extern fn(_: A, _: B, _: C, _: D, _: E) -> Ret`
- `impl<Ret, A, B, C, D, E> Hash for extern fn(_: A, _: B, _: C, _: D, _: E, ...) -> Ret`
- `impl<Ret, A, B, C, D, E> Hash for unsafe fn(_: A, _: B, _: C, _: D, _: E) -> Ret`
- `impl<Ret, A, B, C, D, E> Hash for unsafe extern fn(_: A, _: B, _: C, _: D, _: E) -> Ret`
- `impl<Ret, A, B, C, D, E> Hash for unsafe extern fn(_: A, _: B, _: C, _: D, _: E, ...) -> Ret`
- `impl<Ret, A, B, C, D, E, F> Hash for fn(_: A, _: B, _: C, _: D, _: E, _: F) -> Ret`
- `impl<Ret, A, B, C, D, E, F> Hash for extern fn(_: A, _: B, _: C, _: D, _: E, _: F) -> Ret`
- `impl<Ret, A, B, C, D, E, F> Hash for extern fn(_: A, _: B, _: C, _: D, _: E, _: F, ...) -> Ret`
- `impl<Ret, A, B, C, D, E, F> Hash for unsafe fn(_: A, _: B, _: C, _: D, _: E, _: F) -> Ret`
- `impl<Ret, A, B, C, D, E, F> Hash for unsafe extern fn(_: A, _: B, _: C, _: D, _: E, _: F) -> Ret`
- `impl<Ret, A, B, C, D, E, F> Hash for unsafe extern fn(_: A, _: B, _: C, _: D, _: E, _: F, ...) -> Ret`
- `impl<Ret, A, B, C, D, E, F, G> Hash for fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G) -> Ret`
- `impl<Ret, A, B, C, D, E, F, G> Hash for extern fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G) -> Ret`
- `impl<Ret, A, B, C, D, E, F, G> Hash for extern fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, ...) -> Ret`
- `impl<Ret, A, B, C, D, E, F, G> Hash for unsafe fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G) -> Ret`
- `impl<Ret, A, B, C, D, E, F, G> Hash for unsafe extern fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G) -> Ret`
- `impl<Ret, A, B, C, D, E, F, G> Hash for unsafe extern fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, ...) -> Ret`
- `impl<Ret, A, B, C, D, E, F, G, H> Hash for fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H) -> Ret`
- `impl<Ret, A, B, C, D, E, F, G, H> Hash for extern fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H) -> Ret`
- `impl<Ret, A, B, C, D, E, F, G, H> Hash for extern fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, ...) -> Ret`
- `impl<Ret, A, B, C, D, E, F, G, H> Hash for unsafe fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H) -> Ret`
- `impl<Ret, A, B, C, D, E, F, G, H> Hash for unsafe extern fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H) -> Ret`
- `impl<Ret, A, B, C, D, E, F, G, H> Hash for unsafe extern fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, ...) -> Ret`
- `impl<Ret, A, B, C, D, E, F, G, H, I> Hash for fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, _: I) -> Ret`
- `impl<Ret, A, B, C, D, E, F, G, H, I> Hash for extern fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, _: I) -> Ret`
- `impl<Ret, A, B, C, D, E, F, G, H, I> Hash for extern fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, _: I, ...) -> Ret`
- `impl<Ret, A, B, C, D, E, F, G, H, I> Hash for unsafe fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, _: I) -> Ret`
- `impl<Ret, A, B, C, D, E, F, G, H, I> Hash for unsafe extern fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, _: I) -> Ret`
- `impl<Ret, A, B, C, D, E, F, G, H, I> Hash for unsafe extern fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, _: I, ...) -> Ret`
- `impl<Ret, A, B, C, D, E, F, G, H, I, J> Hash for fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, _: I, _: J) -> Ret`
- `impl<Ret, A, B, C, D, E, F, G, H, I, J> Hash for extern fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, _: I, _: J) -> Ret`
- `impl<Ret, A, B, C, D, E, F, G, H, I, J> Hash for extern fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, _: I, _: J, ...) -> Ret`
- `impl<Ret, A, B, C, D, E, F, G, H, I, J> Hash for unsafe fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, _: I, _: J) -> Ret`
- `impl<Ret, A, B, C, D, E, F, G, H, I, J> Hash for unsafe extern fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, _: I, _: J) -> Ret`
- `impl<Ret, A, B, C, D, E, F, G, H, I, J> Hash for unsafe extern fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, _: I, _: J, ...) -> Ret`
- `impl<Ret, A, B, C, D, E, F, G, H, I, J, K> Hash for fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, _: I, _: J, _: K) -> Ret`
- `impl<Ret, A, B, C, D, E, F, G, H, I, J, K> Hash for extern fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, _: I, _: J, _: K) -> Ret`
- `impl<Ret, A, B, C, D, E, F, G, H, I, J, K> Hash for extern fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, _: I, _: J, _: K, ...) -> Ret`
- `impl<Ret, A, B, C, D, E, F, G, H, I, J, K> Hash for unsafe fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, _: I, _: J, _: K) -> Ret`
- `impl<Ret, A, B, C, D, E, F, G, H, I, J, K> Hash for unsafe extern fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, _: I, _: J, _: K) -> Ret`
- `impl<Ret, A, B, C, D, E, F, G, H, I, J, K> Hash for unsafe extern fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, _: I, _: J, _: K, ...) -> Ret`
- `impl<Ret, A, B, C, D, E, F, G, H, I, J, K, L> Hash for fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, _: I, _: J, _: K, _: L) -> Ret`
- `impl<Ret, A, B, C, D, E, F, G, H, I, J, K, L> Hash for extern fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, _: I, _: J, _: K, _: L) -> Ret`
- `impl<Ret, A, B, C, D, E, F, G, H, I, J, K, L> Hash for extern fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, _: I, _: J, _: K, _: L, ...) -> Ret`
- `impl<Ret, A, B, C, D, E, F, G, H, I, J, K, L> Hash for unsafe fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, _: I, _: J, _: K, _: L) -> Ret`
- `impl<Ret, A, B, C, D, E, F, G, H, I, J, K, L> Hash for unsafe extern fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, _: I, _: J, _: K, _: L) -> Ret`
- `impl<Ret, A, B, C, D, E, F, G, H, I, J, K, L> Hash for unsafe extern fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, _: I, _: J, _: K, _: L, ...) -> Ret`
- `impl<T: ?Sized> Hash for PhantomData<T>`
- `impl Hash for RangeFull`
- `impl<Idx: Hash> Hash for Range<Idx>`
- `impl<Idx: Hash> Hash for RangeFrom<Idx>`
- `impl<Idx: Hash> Hash for RangeTo<Idx>`
- `impl<Idx: Hash> Hash for RangeInclusive<Idx>`
- `impl<Idx: Hash> Hash for RangeToInclusive<Idx>`
- `impl Hash for Ordering`
- `impl Hash for TypeId`
- `impl<T: Hash> Hash for [T; 0]`
- `impl<T: Hash> Hash for [T; 1]`
- `impl<T: Hash> Hash for [T; 2]`
- `impl<T: Hash> Hash for [T; 3]`
- `impl<T: Hash> Hash for [T; 4]`
- `impl<T: Hash> Hash for [T; 5]`
- `impl<T: Hash> Hash for [T; 6]`
- `impl<T: Hash> Hash for [T; 7]`
- `impl<T: Hash> Hash for [T; 8]`
- `impl<T: Hash> Hash for [T; 9]`
- `impl<T: Hash> Hash for [T; 10]`
- `impl<T: Hash> Hash for [T; 11]`
- `impl<T: Hash> Hash for [T; 12]`
- `impl<T: Hash> Hash for [T; 13]`
- `impl<T: Hash> Hash for [T; 14]`
- `impl<T: Hash> Hash for [T; 15]`
- `impl<T: Hash> Hash for [T; 16]`
- `impl<T: Hash> Hash for [T; 17]`
- `impl<T: Hash> Hash for [T; 18]`
- `impl<T: Hash> Hash for [T; 19]`
- `impl<T: Hash> Hash for [T; 20]`
- `impl<T: Hash> Hash for [T; 21]`
- `impl<T: Hash> Hash for [T; 22]`
- `impl<T: Hash> Hash for [T; 23]`
- `impl<T: Hash> Hash for [T; 24]`
- `impl<T: Hash> Hash for [T; 25]`
- `impl<T: Hash> Hash for [T; 26]`
- `impl<T: Hash> Hash for [T; 27]`
- `impl<T: Hash> Hash for [T; 28]`
- `impl<T: Hash> Hash for [T; 29]`
- `impl<T: Hash> Hash for [T; 30]`
- `impl<T: Hash> Hash for [T; 31]`
- `impl<T: Hash> Hash for [T; 32]`
- `impl<T: Hash> Hash for Option<T>`
- `impl<T: Hash, E: Hash> Hash for Result<T, E>`
- `impl Hash for u8`
- `impl Hash for u16`
- `impl Hash for u32`
- `impl Hash for u64`
- `impl Hash for usize`
- `impl Hash for i8`
- `impl Hash for i16`
- `impl Hash for i32`
- `impl Hash for i64`
- `impl Hash for isize`
- `impl Hash for u128`
- `impl Hash for i128`
- `impl Hash for bool`
- `impl Hash for char`
- `impl Hash for str`
- `impl Hash for ()`
- `impl<A: Hash> Hash for (A,)`
- `impl<A: Hash, B: Hash> Hash for (A, B)`
- `impl<A: Hash, B: Hash, C: Hash> Hash for (A, B, C)`
- `impl<A: Hash, B: Hash, C: Hash, D: Hash> Hash for (A, B, C, D)`
- `impl<A: Hash, B: Hash, C: Hash, D: Hash, E: Hash> Hash for (A, B, C, D, E)`
- `impl<A: Hash, B: Hash, C: Hash, D: Hash, E: Hash, F: Hash> Hash for (A, B, C, D, E, F)`
- `impl<A: Hash, B: Hash, C: Hash, D: Hash, E: Hash, F: Hash, G: Hash> Hash for (A, B, C, D, E, F, G)`
- `impl<A: Hash, B: Hash, C: Hash, D: Hash, E: Hash, F: Hash, G: Hash, H: Hash> Hash for (A, B, C, D, E, F, G, H)`
- `impl<A: Hash, B: Hash, C: Hash, D: Hash, E: Hash, F: Hash, G: Hash, H: Hash, I: Hash> Hash for (A, B, C, D, E, F, G, H, I)`
- `impl<A: Hash, B: Hash, C: Hash, D: Hash, E: Hash, F: Hash, G: Hash, H: Hash, I: Hash, J: Hash> Hash for (A, B, C, D, E, F, G, H, I, J)`
- `impl<A: Hash, B: Hash, C: Hash, D: Hash, E: Hash, F: Hash, G: Hash, H: Hash, I: Hash, J: Hash, K: Hash> Hash for (A, B, C, D, E, F, G, H, I, J, K)`
- `impl<A: Hash, B: Hash, C: Hash, D: Hash, E: Hash, F: Hash, G: Hash, H: Hash, I: Hash, J: Hash, K: Hash, L: Hash> Hash for (A, B, C, D, E, F, G, H, I, J, K, L)`
- `impl<T: Hash> Hash for [T]`
- `impl<'a, T: ?Sized + Hash> Hash for &'a T`
- `impl<'a, T: ?Sized + Hash> Hash for &'a mut T`
- `impl<T> Hash for *const T`
- `impl<T> Hash for *mut T`
- `impl Hash for Error`

# Help

## Keyboard Shortcuts

?
  Show this help dialog
S
  Focus the search field
⇤
  Move up in search results
⇥
  Move down in search results
⏎
  Go to active search result
+
  Collapse/expand all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)