W3cubDocs

/Rust

Trait std::hash::BuildHasher

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 of the hasher that will be created.

Required Methods

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();

Implementors

© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/std/hash/trait.BuildHasher.html