# 1.7.0[−][src]Trait core::hash::BuildHasher

    pub trait BuildHasher {
        type Hasher: Hasher;
        fn build_hasher(&self) -> Self::Hasher;
    }

A trait for creating instances of `Hasher`.

A `BuildHasher` is typically used (e.g., by `HashMap`) to create `Hasher`s for each key such that they are hashed independently of one another, since `Hasher`s contain state.

For each instance of `BuildHasher`, the `Hasher`s created by `build_hasher` should be identical. That is, if the same stream of bytes is fed into each hasher, the same output will also be generated.

# Examples

    use std::collections::hash_map::RandomState;
    use std::hash::{BuildHasher, Hasher};

    let s = RandomState::new();
    let mut hasher_1 = s.build_hasher();
    let mut hasher_2 = s.build_hasher();

    hasher_1.write_u32(8128);
    hasher_2.write_u32(8128);

    assert_eq!(hasher_1.finish(), hasher_2.finish());Run

## Associated Types

### `type Hasher: Hasher`

Type of the hasher that will be created.

Loading content...

## Required methods

### `fn build_hasher(&self) -> Self::Hasher`

Creates a new hasher.

Each call to `build_hasher` on the same instance should produce identical `Hasher`s.

# Examples

    use std::collections::hash_map::RandomState;
    use std::hash::BuildHasher;

    let s = RandomState::new();
    let new_s = s.build_hasher();Run

Loading content...

## Implementors

### `impl<H: Default + Hasher> BuildHasher for BuildHasherDefault<H>`[src]

#### `type Hasher = H`

#### `fn build_hasher(&self) -> H`[src]

Loading content...

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse 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`)

Search multiple things at once by splitting your query with comma (e.g., `str,u8` or `String,struct:Vec,test`)