std::hash::BuildHasher - Rust
Description: API documentation for the Rust `BuildHasher` trait in crate `std`.
Keywords: rust, rustlang, rust-lang, BuildHasher

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

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

A `BuildHasher` is typically used as a factory for instances of `Hasher` which a `HashMap` can then use to hash keys independently.

Note that for each instance of `BuildHasher`, the created hashers should be identical. That is, if the same stream of bytes is fed into each hasher, the same output will also be generated.

## Associated Types

### `type Hasher: Hasher`

Type of the hasher that will be created.

## Required Methods

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

Creates a new hasher.

# Examples

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

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

## Implementors

- `impl<H> BuildHasher for BuildHasherDefault<H> where H: Default + Hasher`
- `impl BuildHasher for RandomState`

# 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`)