From 509ead3d35b1d953f439647177b2f974c7562f50 Mon Sep 17 00:00:00 2001 From: Amanieu d'Antras Date: Tue, 18 Jun 2024 15:23:35 +0100 Subject: [PATCH] Use DefaultHashBuilder instead of AHasher in docs and examples --- benches/bench.rs | 2 +- src/lib.rs | 8 ++++ src/map.rs | 20 +++------ src/raw/mod.rs | 6 +-- src/set.rs | 15 ++++--- src/table.rs | 110 ++++++++++++++++------------------------------- tests/hasher.rs | 2 +- 7 files changed, 64 insertions(+), 99 deletions(-) diff --git a/benches/bench.rs b/benches/bench.rs index 346bd7ef89..bfa830825b 100644 --- a/benches/bench.rs +++ b/benches/bench.rs @@ -8,7 +8,7 @@ extern crate test; use test::{black_box, Bencher}; -use hashbrown::hash_map::DefaultHashBuilder; +use hashbrown::DefaultHashBuilder; use hashbrown::{HashMap, HashSet}; use std::{ collections::hash_map::RandomState, diff --git a/src/lib.rs b/src/lib.rs index f03ddb6ad9..3fe8c8b3cf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -39,6 +39,14 @@ #![cfg_attr(feature = "nightly", warn(fuzzy_provenance_casts))] #![cfg_attr(feature = "nightly", allow(internal_features))] +/// Default hasher for [`HashMap`], [`HashSet`] and [`HashTable`]. +#[cfg(feature = "default-hasher")] +pub type DefaultHashBuilder = core::hash::BuildHasherDefault; + +/// Dummy default hasher for [`HashMap`], [`HashSet`] and [`HashTable`]. +#[cfg(not(feature = "default-hasher"))] +pub enum DefaultHashBuilder {} + #[cfg(test)] #[macro_use] extern crate std; diff --git a/src/map.rs b/src/map.rs index d83494eb96..175d5adbdf 100644 --- a/src/map.rs +++ b/src/map.rs @@ -1,7 +1,7 @@ use crate::raw::{ Allocator, Bucket, Global, RawDrain, RawExtractIf, RawIntoIter, RawIter, RawTable, }; -use crate::{Equivalent, TryReserveError}; +use crate::{DefaultHashBuilder, Equivalent, TryReserveError}; use core::borrow::Borrow; use core::fmt::{self, Debug}; use core::hash::{BuildHasher, Hash}; @@ -10,14 +10,6 @@ use core::marker::PhantomData; use core::mem; use core::ops::Index; -/// Default hasher for `HashMap`. -#[cfg(feature = "default-hasher")] -pub type DefaultHashBuilder = core::hash::BuildHasherDefault; - -/// Dummy default hasher for `HashMap`. -#[cfg(not(feature = "default-hasher"))] -pub enum DefaultHashBuilder {} - /// A hash map implemented with quadratic probing and SIMD lookup. /// /// The default hashing algorithm is currently [`AHash`], though this is @@ -447,7 +439,7 @@ impl HashMap { /// /// ``` /// use hashbrown::HashMap; - /// use hashbrown::hash_map::DefaultHashBuilder; + /// use hashbrown::DefaultHashBuilder; /// /// let s = DefaultHashBuilder::default(); /// let mut map = HashMap::with_hasher(s); @@ -489,7 +481,7 @@ impl HashMap { /// /// ``` /// use hashbrown::HashMap; - /// use hashbrown::hash_map::DefaultHashBuilder; + /// use hashbrown::DefaultHashBuilder; /// /// let s = DefaultHashBuilder::default(); /// let mut map = HashMap::with_capacity_and_hasher(10, s); @@ -535,7 +527,7 @@ impl HashMap { /// /// ``` /// use hashbrown::HashMap; - /// use hashbrown::hash_map::DefaultHashBuilder; + /// use hashbrown::DefaultHashBuilder; /// /// let s = DefaultHashBuilder::default(); /// let mut map = HashMap::with_hasher(s); @@ -570,7 +562,7 @@ impl HashMap { /// /// ``` /// use hashbrown::HashMap; - /// use hashbrown::hash_map::DefaultHashBuilder; + /// use hashbrown::DefaultHashBuilder; /// /// let s = DefaultHashBuilder::default(); /// let mut map = HashMap::with_capacity_and_hasher(10, s); @@ -592,7 +584,7 @@ impl HashMap { /// /// ``` /// use hashbrown::HashMap; - /// use hashbrown::hash_map::DefaultHashBuilder; + /// use hashbrown::DefaultHashBuilder; /// /// let hasher = DefaultHashBuilder::default(); /// let map: HashMap = HashMap::with_hasher(hasher); diff --git a/src/raw/mod.rs b/src/raw/mod.rs index 210498351d..db5384641a 100644 --- a/src/raw/mod.rs +++ b/src/raw/mod.rs @@ -483,7 +483,7 @@ impl Bucket { /// use core::hash::{BuildHasher, Hash}; /// use hashbrown::raw::{Bucket, RawTable}; /// - /// type NewHashBuilder = core::hash::BuildHasherDefault; + /// type NewHashBuilder = hashbrown::DefaultHashBuilder; /// /// fn make_hash(hash_builder: &S, key: &K) -> u64 { /// use core::hash::Hasher; @@ -649,7 +649,7 @@ impl Bucket { /// use core::hash::{BuildHasher, Hash}; /// use hashbrown::raw::{Bucket, RawTable}; /// - /// type NewHashBuilder = core::hash::BuildHasherDefault; + /// type NewHashBuilder = hashbrown::DefaultHashBuilder; /// /// fn make_hash(hash_builder: &S, key: &K) -> u64 { /// use core::hash::Hasher; @@ -708,7 +708,7 @@ impl Bucket { /// use core::hash::{BuildHasher, Hash}; /// use hashbrown::raw::{Bucket, RawTable}; /// - /// type NewHashBuilder = core::hash::BuildHasherDefault; + /// type NewHashBuilder = hashbrown::DefaultHashBuilder; /// /// fn make_hash(hash_builder: &S, key: &K) -> u64 { /// use core::hash::Hasher; diff --git a/src/set.rs b/src/set.rs index be03b87038..3a7874f039 100644 --- a/src/set.rs +++ b/src/set.rs @@ -7,8 +7,9 @@ use core::hash::{BuildHasher, Hash}; use core::iter::{Chain, FusedIterator}; use core::ops::{BitAnd, BitOr, BitXor, Sub}; -use super::map::{self, DefaultHashBuilder, HashMap, Keys}; +use super::map::{self, HashMap, Keys}; use crate::raw::{Allocator, Global, RawExtractIf}; +use crate::DefaultHashBuilder; // Future Optimization (FIXME!) // ============================= @@ -459,7 +460,7 @@ impl HashSet { /// /// ``` /// use hashbrown::HashSet; - /// use hashbrown::hash_map::DefaultHashBuilder; + /// use hashbrown::DefaultHashBuilder; /// /// let s = DefaultHashBuilder::default(); /// let mut set = HashSet::with_hasher(s); @@ -497,7 +498,7 @@ impl HashSet { /// /// ``` /// use hashbrown::HashSet; - /// use hashbrown::hash_map::DefaultHashBuilder; + /// use hashbrown::DefaultHashBuilder; /// /// let s = DefaultHashBuilder::default(); /// let mut set = HashSet::with_capacity_and_hasher(10, s); @@ -546,7 +547,7 @@ where /// /// ``` /// use hashbrown::HashSet; - /// use hashbrown::hash_map::DefaultHashBuilder; + /// use hashbrown::DefaultHashBuilder; /// /// let s = DefaultHashBuilder::default(); /// let mut set = HashSet::with_hasher(s); @@ -584,7 +585,7 @@ where /// /// ``` /// use hashbrown::HashSet; - /// use hashbrown::hash_map::DefaultHashBuilder; + /// use hashbrown::DefaultHashBuilder; /// /// let s = DefaultHashBuilder::default(); /// let mut set = HashSet::with_capacity_and_hasher(10, s); @@ -605,7 +606,7 @@ where /// /// ``` /// use hashbrown::HashSet; - /// use hashbrown::hash_map::DefaultHashBuilder; + /// use hashbrown::DefaultHashBuilder; /// /// let hasher = DefaultHashBuilder::default(); /// let set: HashSet = HashSet::with_hasher(hasher); @@ -2497,8 +2498,8 @@ fn assert_covariance() { #[cfg(test)] mod test_set { - use super::super::map::DefaultHashBuilder; use super::HashSet; + use crate::DefaultHashBuilder; use std::vec::Vec; #[test] diff --git a/src/table.rs b/src/table.rs index faf8a6330f..d044a1971e 100644 --- a/src/table.rs +++ b/src/table.rs @@ -103,14 +103,13 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { - /// use ahash::AHasher; /// use bumpalo::Bump; - /// use hashbrown::HashTable; + /// use hashbrown::{HashTable, DefaultHashBuilder}; /// use std::hash::{BuildHasher, BuildHasherDefault}; /// /// let bump = Bump::new(); /// let mut table = HashTable::new_in(&bump); - /// let hasher = BuildHasherDefault::::default(); + /// let hasher = DefaultHashBuilder::default(); /// let hasher = |val: &_| hasher.hash_one(val); /// /// // The created HashTable holds none elements @@ -147,14 +146,13 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { - /// use ahash::AHasher; /// use bumpalo::Bump; /// use hashbrown::HashTable; /// use std::hash::{BuildHasher, BuildHasherDefault}; /// /// let bump = Bump::new(); /// let mut table = HashTable::with_capacity_in(5, &bump); - /// let hasher = BuildHasherDefault::::default(); + /// let hasher = DefaultHashBuilder::default(); /// let hasher = |val: &_| hasher.hash_one(val); /// /// // The created HashTable holds none elements @@ -203,12 +201,11 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { - /// use ahash::AHasher; /// use hashbrown::HashTable; /// use std::hash::{BuildHasher, BuildHasherDefault}; /// /// let mut table = HashTable::new(); - /// let hasher = BuildHasherDefault::::default(); + /// let hasher = DefaultHashBuilder::default(); /// let hasher = |val: &_| hasher.hash_one(val); /// table.insert_unique(hasher(&1), 1, hasher); /// table.insert_unique(hasher(&2), 2, hasher); @@ -241,12 +238,11 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { - /// use ahash::AHasher; /// use hashbrown::HashTable; /// use std::hash::{BuildHasher, BuildHasherDefault}; /// /// let mut table = HashTable::new(); - /// let hasher = BuildHasherDefault::::default(); + /// let hasher = DefaultHashBuilder::default(); /// let hasher = |val: &_| hasher.hash_one(val); /// table.insert_unique(hasher(&1), (1, "a"), |val| hasher(&val.0)); /// if let Some(val) = table.find_mut(hasher(&1), |val| val.0 == 1) { @@ -280,12 +276,11 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { - /// use ahash::AHasher; /// use hashbrown::HashTable; /// use std::hash::{BuildHasher, BuildHasherDefault}; /// /// let mut table = HashTable::new(); - /// let hasher = BuildHasherDefault::::default(); + /// let hasher = DefaultHashBuilder::default(); /// let hasher = |val: &_| hasher.hash_one(val); /// table.insert_unique(hasher(&1), (1, "a"), |val| hasher(&val.0)); /// if let Ok(entry) = table.find_entry(hasher(&1), |val| val.0 == 1) { @@ -335,13 +330,12 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { - /// use ahash::AHasher; /// use hashbrown::hash_table::Entry; /// use hashbrown::HashTable; /// use std::hash::{BuildHasher, BuildHasherDefault}; /// /// let mut table = HashTable::new(); - /// let hasher = BuildHasherDefault::::default(); + /// let hasher = DefaultHashBuilder::default(); /// let hasher = |val: &_| hasher.hash_one(val); /// table.insert_unique(hasher(&1), (1, "a"), |val| hasher(&val.0)); /// if let Entry::Occupied(entry) = table.entry(hasher(&1), |val| val.0 == 1, |val| hasher(&val.0)) @@ -392,12 +386,11 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { - /// use ahash::AHasher; /// use hashbrown::HashTable; /// use std::hash::{BuildHasher, BuildHasherDefault}; /// /// let mut v = HashTable::new(); - /// let hasher = BuildHasherDefault::::default(); + /// let hasher = DefaultHashBuilder::default(); /// let hasher = |val: &_| hasher.hash_one(val); /// v.insert_unique(hasher(&1), 1, hasher); /// # } @@ -427,12 +420,11 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { - /// use ahash::AHasher; /// use hashbrown::HashTable; /// use std::hash::{BuildHasher, BuildHasherDefault}; /// /// let mut v = HashTable::new(); - /// let hasher = BuildHasherDefault::::default(); + /// let hasher = DefaultHashBuilder::default(); /// let hasher = |val: &_| hasher.hash_one(val); /// v.insert_unique(hasher(&1), 1, hasher); /// v.clear(); @@ -459,12 +451,11 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { - /// use ahash::AHasher; /// use hashbrown::HashTable; /// use std::hash::{BuildHasher, BuildHasherDefault}; /// /// let mut table = HashTable::with_capacity(100); - /// let hasher = BuildHasherDefault::::default(); + /// let hasher = DefaultHashBuilder::default(); /// let hasher = |val: &_| hasher.hash_one(val); /// table.insert_unique(hasher(&1), 1, hasher); /// table.insert_unique(hasher(&2), 2, hasher); @@ -496,12 +487,11 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { - /// use ahash::AHasher; /// use hashbrown::HashTable; /// use std::hash::{BuildHasher, BuildHasherDefault}; /// /// let mut table = HashTable::with_capacity(100); - /// let hasher = BuildHasherDefault::::default(); + /// let hasher = DefaultHashBuilder::default(); /// let hasher = |val: &_| hasher.hash_one(val); /// table.insert_unique(hasher(&1), 1, hasher); /// table.insert_unique(hasher(&2), 2, hasher); @@ -541,12 +531,11 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { - /// use ahash::AHasher; /// use hashbrown::HashTable; /// use std::hash::{BuildHasher, BuildHasherDefault}; /// /// let mut table: HashTable = HashTable::new(); - /// let hasher = BuildHasherDefault::::default(); + /// let hasher = DefaultHashBuilder::default(); /// let hasher = |val: &_| hasher.hash_one(val); /// table.reserve(10, hasher); /// assert!(table.capacity() >= 10); @@ -577,12 +566,11 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { - /// use ahash::AHasher; /// use hashbrown::HashTable; /// use std::hash::{BuildHasher, BuildHasherDefault}; /// /// let mut table: HashTable = HashTable::new(); - /// let hasher = BuildHasherDefault::::default(); + /// let hasher = DefaultHashBuilder::default(); /// let hasher = |val: &_| hasher.hash_one(val); /// table /// .try_reserve(10, hasher) @@ -621,11 +609,10 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { - /// use ahash::AHasher; /// use hashbrown::HashTable; /// use std::hash::{BuildHasher, BuildHasherDefault}; /// - /// let hasher = BuildHasherDefault::::default(); + /// let hasher = DefaultHashBuilder::default(); /// let hasher = |val: &_| hasher.hash_one(val); /// let mut v = HashTable::new(); /// assert_eq!(v.len(), 0); @@ -648,11 +635,10 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { - /// use ahash::AHasher; /// use hashbrown::HashTable; /// use std::hash::{BuildHasher, BuildHasherDefault}; /// - /// let hasher = BuildHasherDefault::::default(); + /// let hasher = DefaultHashBuilder::default(); /// let hasher = |val: &_| hasher.hash_one(val); /// let mut v = HashTable::new(); /// assert!(v.is_empty()); @@ -676,12 +662,11 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { - /// use ahash::AHasher; /// use hashbrown::HashTable; /// use std::hash::{BuildHasher, BuildHasherDefault}; /// /// let mut table = HashTable::new(); - /// let hasher = BuildHasherDefault::::default(); + /// let hasher = DefaultHashBuilder::default(); /// let hasher = |val: &_| hasher.hash_one(val); /// table.insert_unique(hasher(&"a"), "b", hasher); /// table.insert_unique(hasher(&"b"), "b", hasher); @@ -712,12 +697,11 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { - /// use ahash::AHasher; /// use hashbrown::HashTable; /// use std::hash::{BuildHasher, BuildHasherDefault}; /// /// let mut table = HashTable::new(); - /// let hasher = BuildHasherDefault::::default(); + /// let hasher = DefaultHashBuilder::default(); /// let hasher = |val: &_| hasher.hash_one(val); /// table.insert_unique(hasher(&1), 1, hasher); /// table.insert_unique(hasher(&2), 2, hasher); @@ -764,12 +748,11 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { - /// use ahash::AHasher; /// use hashbrown::HashTable; /// use std::hash::{BuildHasher, BuildHasherDefault}; /// /// let mut table = HashTable::new(); - /// let hasher = BuildHasherDefault::::default(); + /// let hasher = DefaultHashBuilder::default(); /// let hasher = |val: &_| hasher.hash_one(val); /// for x in 1..=6 { /// table.insert_unique(hasher(&x), x, hasher); @@ -800,12 +783,11 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { - /// use ahash::AHasher; /// use hashbrown::HashTable; /// use std::hash::{BuildHasher, BuildHasherDefault}; /// /// let mut table = HashTable::new(); - /// let hasher = BuildHasherDefault::::default(); + /// let hasher = DefaultHashBuilder::default(); /// let hasher = |val: &_| hasher.hash_one(val); /// for x in 1..=3 { /// table.insert_unique(hasher(&x), x, hasher); @@ -847,12 +829,11 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { - /// use ahash::AHasher; /// use hashbrown::HashTable; /// use std::hash::{BuildHasher, BuildHasherDefault}; /// /// let mut table = HashTable::new(); - /// let hasher = BuildHasherDefault::::default(); + /// let hasher = DefaultHashBuilder::default(); /// let hasher = |val: &_| hasher.hash_one(val); /// for x in 0..8 { /// table.insert_unique(hasher(&x), x, hasher); @@ -899,13 +880,12 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { - /// use ahash::AHasher; /// use hashbrown::hash_table::Entry; /// use hashbrown::HashTable; /// use std::hash::{BuildHasher, BuildHasherDefault}; /// /// let mut libraries: HashTable<(&str, u32)> = HashTable::new(); - /// let hasher = BuildHasherDefault::::default(); + /// let hasher = DefaultHashBuilder::default(); /// let hasher = |val: &_| hasher.hash_one(val); /// for (k, v) in [ /// ("Bodleian Library", 1602), @@ -969,13 +949,12 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { - /// use ahash::AHasher; /// use hashbrown::hash_table::Entry; /// use hashbrown::HashTable; /// use std::hash::{BuildHasher, BuildHasherDefault}; /// /// let mut libraries: HashTable<(&str, u32)> = HashTable::new(); - /// let hasher = BuildHasherDefault::::default(); + /// let hasher = DefaultHashBuilder::default(); /// let hasher = |val: &_| hasher.hash_one(val); /// for (k, v) in [ /// ("Bodleian Library", 1602), @@ -1100,12 +1079,11 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { -/// use ahash::AHasher; /// use hashbrown::hash_table::{Entry, HashTable, OccupiedEntry}; /// use std::hash::{BuildHasher, BuildHasherDefault}; /// /// let mut table = HashTable::new(); -/// let hasher = BuildHasherDefault::::default(); +/// let hasher = DefaultHashBuilder::default(); /// let hasher = |val: &_| hasher.hash_one(val); /// for x in ["a", "b", "c"] { /// table.insert_unique(hasher(&x), x, hasher); @@ -1152,12 +1130,11 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { - /// use ahash::AHasher; /// use hashbrown::hash_table::{Entry, HashTable, OccupiedEntry}; /// use std::hash::{BuildHasher, BuildHasherDefault}; /// /// let mut table = HashTable::new(); - /// let hasher = BuildHasherDefault::::default(); + /// let hasher = DefaultHashBuilder::default(); /// let hasher = |val: &_| hasher.hash_one(val); /// for x in ["a", "b"] { /// table.insert_unique(hasher(&x), x, hasher); @@ -1182,12 +1159,11 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { - /// use ahash::AHasher; /// use hashbrown::hash_table::{Entry, HashTable, OccupiedEntry}; /// use std::hash::{BuildHasher, BuildHasherDefault}; /// /// let mut table = HashTable::<&str>::new(); - /// let hasher = BuildHasherDefault::::default(); + /// let hasher = DefaultHashBuilder::default(); /// let hasher = |val: &_| hasher.hash_one(val); /// /// match table.entry(hasher(&"a"), |&x| x == "a", hasher) { @@ -1224,12 +1200,11 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { - /// use ahash::AHasher; /// use hashbrown::HashTable; /// use std::hash::{BuildHasher, BuildHasherDefault}; /// /// let mut table: HashTable<&str> = HashTable::new(); - /// let hasher = BuildHasherDefault::::default(); + /// let hasher = DefaultHashBuilder::default(); /// let hasher = |val: &_| hasher.hash_one(val); /// /// let entry = table @@ -1262,12 +1237,11 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { - /// use ahash::AHasher; /// use hashbrown::HashTable; /// use std::hash::{BuildHasher, BuildHasherDefault}; /// /// let mut table: HashTable<&str> = HashTable::new(); - /// let hasher = BuildHasherDefault::::default(); + /// let hasher = DefaultHashBuilder::default(); /// let hasher = |val: &_| hasher.hash_one(val); /// /// // nonexistent key @@ -1308,12 +1282,11 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { - /// use ahash::AHasher; /// use hashbrown::HashTable; /// use std::hash::{BuildHasher, BuildHasherDefault}; /// /// let mut table: HashTable = HashTable::new(); - /// let hasher = BuildHasherDefault::::default(); + /// let hasher = DefaultHashBuilder::default(); /// let hasher = |val: &_| hasher.hash_one(val); /// /// table @@ -1344,12 +1317,11 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { - /// use ahash::AHasher; /// use hashbrown::HashTable; /// use std::hash::{BuildHasher, BuildHasherDefault}; /// /// let mut table: HashTable<(&str, u32)> = HashTable::new(); - /// let hasher = BuildHasherDefault::::default(); + /// let hasher = DefaultHashBuilder::default(); /// let hasher = |val: &_| hasher.hash_one(val); /// /// table @@ -1404,12 +1376,11 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { -/// use ahash::AHasher; /// use hashbrown::hash_table::{Entry, HashTable, OccupiedEntry}; /// use std::hash::{BuildHasher, BuildHasherDefault}; /// /// let mut table = HashTable::new(); -/// let hasher = BuildHasherDefault::::default(); +/// let hasher = DefaultHashBuilder::default(); /// let hasher = |val: &_| hasher.hash_one(val); /// for x in ["a", "b", "c"] { /// table.insert_unique(hasher(&x), x, hasher); @@ -1487,13 +1458,12 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { - /// use ahash::AHasher; /// use hashbrown::hash_table::Entry; /// use hashbrown::HashTable; /// use std::hash::{BuildHasher, BuildHasherDefault}; /// /// let mut table: HashTable<&str> = HashTable::new(); - /// let hasher = BuildHasherDefault::::default(); + /// let hasher = DefaultHashBuilder::default(); /// let hasher = |val: &_| hasher.hash_one(val); /// // The table is empty /// assert!(table.is_empty() && table.capacity() == 0); @@ -1536,13 +1506,12 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { - /// use ahash::AHasher; /// use hashbrown::hash_table::Entry; /// use hashbrown::HashTable; /// use std::hash::{BuildHasher, BuildHasherDefault}; /// /// let mut table: HashTable<&str> = HashTable::new(); - /// let hasher = BuildHasherDefault::::default(); + /// let hasher = DefaultHashBuilder::default(); /// let hasher = |val: &_| hasher.hash_one(val); /// table.insert_unique(hasher(&"poneyland"), "poneyland", hasher); /// @@ -1573,13 +1542,12 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { - /// use ahash::AHasher; /// use hashbrown::hash_table::Entry; /// use hashbrown::HashTable; /// use std::hash::{BuildHasher, BuildHasherDefault}; /// /// let mut table: HashTable<(&str, u32)> = HashTable::new(); - /// let hasher = BuildHasherDefault::::default(); + /// let hasher = DefaultHashBuilder::default(); /// let hasher = |val: &_| hasher.hash_one(val); /// table.insert_unique(hasher(&"poneyland"), ("poneyland", 12), |(k, _)| hasher(&k)); /// @@ -1627,13 +1595,12 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { - /// use ahash::AHasher; /// use hashbrown::hash_table::Entry; /// use hashbrown::HashTable; /// use std::hash::{BuildHasher, BuildHasherDefault}; /// /// let mut table: HashTable<(&str, u32)> = HashTable::new(); - /// let hasher = BuildHasherDefault::::default(); + /// let hasher = DefaultHashBuilder::default(); /// let hasher = |val: &_| hasher.hash_one(val); /// table.insert_unique(hasher(&"poneyland"), ("poneyland", 12), |(k, _)| hasher(&k)); /// @@ -1684,12 +1651,11 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { -/// use ahash::AHasher; /// use hashbrown::hash_table::{Entry, HashTable, VacantEntry}; /// use std::hash::{BuildHasher, BuildHasherDefault}; /// /// let mut table: HashTable<&str> = HashTable::new(); -/// let hasher = BuildHasherDefault::::default(); +/// let hasher = DefaultHashBuilder::default(); /// let hasher = |val: &_| hasher.hash_one(val); /// /// let entry_v: VacantEntry<_, _> = match table.entry(hasher(&"a"), |&x| x == "a", hasher) { @@ -1742,13 +1708,12 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { - /// use ahash::AHasher; /// use hashbrown::hash_table::Entry; /// use hashbrown::HashTable; /// use std::hash::{BuildHasher, BuildHasherDefault}; /// /// let mut table: HashTable<&str> = HashTable::new(); - /// let hasher = BuildHasherDefault::::default(); + /// let hasher = DefaultHashBuilder::default(); /// let hasher = |val: &_| hasher.hash_one(val); /// /// if let Entry::Vacant(o) = table.entry(hasher(&"poneyland"), |&x| x == "poneyland", hasher) { @@ -1798,12 +1763,11 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { -/// use ahash::AHasher; /// use hashbrown::hash_table::{AbsentEntry, Entry, HashTable}; /// use std::hash::{BuildHasher, BuildHasherDefault}; /// /// let mut table: HashTable<&str> = HashTable::new(); -/// let hasher = BuildHasherDefault::::default(); +/// let hasher = DefaultHashBuilder::default(); /// let hasher = |val: &_| hasher.hash_one(val); /// /// let entry_v: AbsentEntry<_, _> = table.find_entry(hasher(&"a"), |&x| x == "a").unwrap_err(); diff --git a/tests/hasher.rs b/tests/hasher.rs index e455e3d3c9..f6920108b2 100644 --- a/tests/hasher.rs +++ b/tests/hasher.rs @@ -23,7 +23,7 @@ fn check() { /// Use hashbrown's default hasher. #[test] fn default() { - check::(); + check::(); } /// Use std's default hasher.