Struct BuildHasherDefault

struct BuildHasherDefault<H>(_)

Used to create a default BuildHasher instance for types that implement Hasher and Default.

BuildHasherDefault<H> can be used when a type H implements Hasher and Default, and you need a corresponding BuildHasher instance, but none is defined.

Any BuildHasherDefault is zero-sized. It can be created with default. When using BuildHasherDefault with HashMap or HashSet, this doesn't need to be done, since they implement appropriate Default instances themselves.

Examples

Using BuildHasherDefault to specify a custom BuildHasher for HashMap:

use std::collections::HashMap;
use std::hash::{BuildHasherDefault, Hasher};

#[derive(Default)]
struct MyHasher;

impl Hasher for MyHasher {
    fn write(&mut self, bytes: &[u8]) {
        // Your hashing algorithm goes here!
       unimplemented!()
    }

    fn finish(&self) -> u64 {
        // Your hashing algorithm goes here!
        unimplemented!()
    }
}

type MyBuildHasher = BuildHasherDefault<MyHasher>;

let hash_map = HashMap::<u32, u32, MyBuildHasher>::default();

Implementations

impl<H> BuildHasherDefault<H>

const fn new() -> Self

Creates a new BuildHasherDefault for Hasher H.

impl<H> Clone for BuildHasherDefault<H>

fn clone(self: &Self) -> BuildHasherDefault<H>

impl<H> Debug for BuildHasherDefault<H>

fn fmt(self: &Self, f: &mut fmt::Formatter<'_>) -> fmt::Result

impl<H> Default for BuildHasherDefault<H>

fn default() -> BuildHasherDefault<H>

impl<H> Eq for BuildHasherDefault<H>

impl<H> Freeze for BuildHasherDefault<H>

impl<H> PartialEq for BuildHasherDefault<H>

fn eq(self: &Self, _other: &BuildHasherDefault<H>) -> bool

impl<H> RefUnwindSafe for BuildHasherDefault<H>

impl<H> Send for BuildHasherDefault<H>

impl<H> Sync for BuildHasherDefault<H>

impl<H> Unpin for BuildHasherDefault<H>

impl<H> UnwindSafe for BuildHasherDefault<H>

impl<H: Default + Hasher> BuildHasher for BuildHasherDefault<H>

fn build_hasher(self: &Self) -> H

impl<T> Any for BuildHasherDefault<H>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for BuildHasherDefault<H>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for BuildHasherDefault<H>

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> CloneToUninit for BuildHasherDefault<H>

unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)

impl<T> From for BuildHasherDefault<H>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T, U> Into for BuildHasherDefault<H>

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for BuildHasherDefault<H>

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for BuildHasherDefault<H>

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>