Movatterモバイル変換


[0]ホーム

URL:


Docs.rs

hashbrown/
hasher.rs

1#[cfg(feature ="default-hasher")]2use{3    core::hash::{BuildHasher,Hasher},4foldhash::fast::RandomState,5};67/// Default hash builder for the `S` type parameter of8/// [`HashMap`](crate::HashMap) and [`HashSet`](crate::HashSet).9///10/// This only implements `BuildHasher` when the "default-hasher" crate feature11/// is enabled; otherwise it just serves as a placeholder, and a custom `S` type12/// must be used to have a fully functional `HashMap` or `HashSet`.13#[derive(Clone, Debug, Default)]14pub structDefaultHashBuilder {15#[cfg(feature ="default-hasher")]16inner:RandomState,17}1819#[cfg(feature ="default-hasher")]20implBuildHasherforDefaultHashBuilder {21typeHasher =DefaultHasher;2223#[inline(always)]24fnbuild_hasher(&self) ->Self::Hasher {25DefaultHasher {26            inner:self.inner.build_hasher(),27        }28    }29}3031/// Default hasher for [`HashMap`](crate::HashMap) and [`HashSet`](crate::HashSet).32#[cfg(feature ="default-hasher")]33#[derive(Clone)]34pub structDefaultHasher {35    inner: <RandomStateasBuildHasher>::Hasher,36}3738#[cfg(feature ="default-hasher")]39macro_rules! forward_writes {40    ($($write:ident ($ty:ty ) , )*) => {$(41#[inline(always)]42fn$write(&mutself, arg:$ty) {43self.inner.$write(arg);44        }45    )*}46}4748#[cfg(feature ="default-hasher")]49implHasherforDefaultHasher {50forward_writes! {51        write(&[u8]),52        write_u8(u8),53        write_u16(u16),54        write_u32(u32),55        write_u64(u64),56        write_u128(u128),57        write_usize(usize),58        write_i8(i8),59        write_i16(i16),60        write_i32(i32),61        write_i64(i64),62        write_i128(i128),63        write_isize(isize),64    }6566// feature(hasher_prefixfree_extras)67#[cfg(feature ="nightly")]68forward_writes! {69        write_length_prefix(usize),70        write_str(&str),71    }7273#[inline(always)]74fnfinish(&self) ->u64 {75self.inner.finish()76    }77}

[8]ページ先頭

©2009-2025 Movatter.jp