diff --git a/benches/general_ops.rs b/benches/general_ops.rs index 1a95e5234..a5f931d2a 100644 --- a/benches/general_ops.rs +++ b/benches/general_ops.rs @@ -2,14 +2,14 @@ //! * Hasher: std default (SipHash) and crate default (foldhash). //! * Int key distribution: low bit heavy, top bit heavy, and random. //! * Task: basic functionality: insert, insert_erase, lookup, lookup_fail, iter -use criterion::Criterion; -use hashbrown::DefaultHashBuilder; -use hashbrown::{HashMap, HashSet}; -use std::{ - collections::hash_map::RandomState, +use core::{ hint::black_box, sync::atomic::{self, AtomicUsize}, }; +use criterion::Criterion; +use hashbrown::DefaultHashBuilder; +use hashbrown::{HashMap, HashSet}; +use std::hash::RandomState; const SIZE: usize = 1000; const OP_COUNT: usize = 500; diff --git a/benches/insert_unique_unchecked.rs b/benches/insert_unique_unchecked.rs index 402a21820..cfd7781e3 100644 --- a/benches/insert_unique_unchecked.rs +++ b/benches/insert_unique_unchecked.rs @@ -1,7 +1,7 @@ //! Compare `insert` and `insert_unique_unchecked` operations performance. +use core::hint::black_box; use criterion::Criterion; use hashbrown::HashMap; -use std::hint::black_box; pub(crate) fn register_benches(c: &mut Criterion) { let keys: Vec = (0..1000).map(|i| format!("xxxx{i}yyyy")).collect(); diff --git a/benches/with_capacity.rs b/benches/with_capacity.rs index c12992442..8b518e975 100644 --- a/benches/with_capacity.rs +++ b/benches/with_capacity.rs @@ -1,6 +1,6 @@ +use core::hint::black_box; use criterion::Criterion; use hashbrown::HashMap; -use std::hint::black_box; type Map = HashMap; diff --git a/src/map.rs b/src/map.rs index 877261067..669488cbb 100644 --- a/src/map.rs +++ b/src/map.rs @@ -133,8 +133,8 @@ pub use crate::raw_entry::*; /// The easiest way to use `HashMap` with a custom key type is to derive [`Eq`] and [`Hash`]. /// We must also derive [`PartialEq`]. /// -/// [`RefCell`]: std::cell::RefCell -/// [`Cell`]: std::cell::Cell +/// [`Cell`]: core::cell::Cell +/// [`RefCell`]: core::cell::RefCell /// [`default`]: Default::default /// [`with_hasher`]: HashMap::with_hasher /// [`with_capacity_and_hasher`]: HashMap::with_capacity_and_hasher @@ -2669,13 +2669,13 @@ pub struct ValuesMut<'a, K, V> { /// /// // Existing key (or_insert) /// let v = map.entry("b").or_insert(2); -/// assert_eq!(std::mem::replace(v, 2), 20); +/// assert_eq!(core::mem::replace(v, 2), 20); /// // Nonexistent key (or_insert) /// map.entry("e").or_insert(5); /// /// // Existing key (or_insert_with) /// let v = map.entry("c").or_insert_with(|| 3); -/// assert_eq!(std::mem::replace(v, 3), 30); +/// assert_eq!(core::mem::replace(v, 3), 30); /// // Nonexistent key (or_insert_with) /// map.entry("f").or_insert_with(|| 6); /// @@ -2872,13 +2872,13 @@ impl Debug for VacantEntry<'_, K, V, S, A> { /// /// // Existing key (or_insert) /// let v = map.entry_ref("b").or_insert(2); -/// assert_eq!(std::mem::replace(v, 2), 20); +/// assert_eq!(core::mem::replace(v, 2), 20); /// // Nonexistent key (or_insert) /// map.entry_ref("e").or_insert(5); /// /// // Existing key (or_insert_with) /// let v = map.entry_ref("c").or_insert_with(|| 3); -/// assert_eq!(std::mem::replace(v, 3), 30); +/// assert_eq!(core::mem::replace(v, 3), 30); /// // Nonexistent key (or_insert_with) /// map.entry_ref("f").or_insert_with(|| 6); /// @@ -3809,8 +3809,8 @@ impl<'a, K, V, S, A: Allocator> OccupiedEntry<'a, K, V, S, A> { /// Entry::Vacant(_) => panic!(), /// Entry::Occupied(mut entry) => { /// let replaced = entry.replace_key(new_key); - /// assert!(std::ptr::eq(replaced, old_key)); - /// assert!(std::ptr::eq(*entry.key(), new_key)); + /// assert!(core::ptr::eq(replaced, old_key)); + /// assert!(core::ptr::eq(*entry.key(), new_key)); /// }, /// } /// @@ -3864,8 +3864,8 @@ impl<'a, K, V, S, A: Allocator> OccupiedEntry<'a, K, V, S, A> { /// Entry::Vacant(_) => panic!(), /// Entry::Occupied(mut entry) => { /// let replaced = unsafe { entry.replace_key_unchecked(new_key) }; - /// assert!(std::ptr::eq(replaced, old_key)); - /// assert!(std::ptr::eq(*entry.key(), new_key)); + /// assert!(core::ptr::eq(replaced, old_key)); + /// assert!(core::ptr::eq(*entry.key(), new_key)); /// }, /// } /// @@ -5084,11 +5084,11 @@ mod test_map { use super::HashMap; use crate::alloc::{AllocError, Allocator, Global}; use core::alloc::Layout; + use core::cell::RefCell; use core::ptr::NonNull; use core::sync::atomic::{AtomicI8, Ordering}; use rand::{Rng, SeedableRng, rngs::SmallRng}; use std::borrow::ToOwned; - use std::cell::RefCell; use std::vec::Vec; use stdalloc::string::String; use stdalloc::sync::Arc; @@ -6043,7 +6043,7 @@ mod test_map { #[test] fn test_extend_ref_kv_tuple() { - use std::ops::AddAssign; + use core::ops::AddAssign; let mut a = HashMap::new(); a.insert(0, 0); diff --git a/src/set.rs b/src/set.rs index f3f526dc6..2aa9ca5cd 100644 --- a/src/set.rs +++ b/src/set.rs @@ -106,8 +106,8 @@ use crate::raw::RawExtractIf; /// // use the values stored in the set /// ``` /// -/// [`Cell`]: std::cell::Cell -/// [`RefCell`]: std::cell::RefCell +/// [`Cell`]: core::cell::Cell +/// [`RefCell`]: core::cell::RefCell pub struct HashSet { pub(crate) map: HashMap, } diff --git a/src/table.rs b/src/table.rs index ac201bf62..c65afa5c2 100644 --- a/src/table.rs +++ b/src/table.rs @@ -109,8 +109,8 @@ where /// # #[cfg(feature = "nightly")] /// # fn test() { /// use bumpalo::Bump; + /// use core::hash::BuildHasher; /// use hashbrown::{HashTable, DefaultHashBuilder}; - /// use std::hash::BuildHasher; /// /// let bump = Bump::new(); /// let mut table = HashTable::new_in(&bump); @@ -153,8 +153,8 @@ where /// # #[cfg(feature = "nightly")] /// # fn test() { /// use bumpalo::Bump; + /// use core::hash::BuildHasher; /// use hashbrown::{HashTable, DefaultHashBuilder}; - /// use std::hash::BuildHasher; /// /// let bump = Bump::new(); /// let mut table = HashTable::with_capacity_in(5, &bump); @@ -208,8 +208,8 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { + /// use core::hash::BuildHasher; /// use hashbrown::{HashTable, DefaultHashBuilder}; - /// use std::hash::BuildHasher; /// /// let mut table = HashTable::new(); /// let hasher = DefaultHashBuilder::default(); @@ -245,8 +245,8 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { + /// use core::hash::BuildHasher; /// use hashbrown::{HashTable, DefaultHashBuilder}; - /// use std::hash::BuildHasher; /// /// let mut table = HashTable::new(); /// let hasher = DefaultHashBuilder::default(); @@ -283,8 +283,8 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { + /// use core::hash::BuildHasher; /// use hashbrown::{HashTable, DefaultHashBuilder}; - /// use std::hash::BuildHasher; /// /// let mut table = HashTable::new(); /// let hasher = DefaultHashBuilder::default(); @@ -330,8 +330,8 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { + /// use core::hash::BuildHasher; /// use hashbrown::{HashTable, DefaultHashBuilder}; - /// use std::hash::BuildHasher; /// /// let mut table = HashTable::new(); /// let hasher = DefaultHashBuilder::default(); @@ -385,9 +385,9 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { + /// use core::hash::BuildHasher; /// use hashbrown::hash_table::Entry; /// use hashbrown::{HashTable, DefaultHashBuilder}; - /// use std::hash::BuildHasher; /// /// let mut table = HashTable::new(); /// let hasher = DefaultHashBuilder::default(); @@ -436,8 +436,8 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { + /// use core::hash::BuildHasher; /// use hashbrown::{HashTable, DefaultHashBuilder}; - /// use std::hash::BuildHasher; /// /// let mut table = HashTable::new(); /// let hasher = DefaultHashBuilder::default(); @@ -492,8 +492,8 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { + /// use core::hash::BuildHasher; /// use hashbrown::{HashTable, DefaultHashBuilder}; - /// use std::hash::BuildHasher; /// /// let mut table = HashTable::new(); /// let hasher = DefaultHashBuilder::default(); @@ -503,7 +503,7 @@ where /// table.insert_unique(hasher(&3), (3, 'c'), |val| hasher(&val.0)); /// /// let index = table.find_bucket_index(hasher(&2), |val| val.0 == 2).unwrap(); - /// assert!(std::ptr::eq( + /// assert!(core::ptr::eq( /// table.get_bucket_entry(index).unwrap().into_mut(), /// unsafe { table.get_bucket_entry_unchecked(index).into_mut() }, /// )); @@ -529,8 +529,8 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { + /// use core::hash::BuildHasher; /// use hashbrown::{HashTable, DefaultHashBuilder}; - /// use std::hash::BuildHasher; /// /// let mut table = HashTable::new(); /// let hasher = DefaultHashBuilder::default(); @@ -569,8 +569,8 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { + /// use core::hash::BuildHasher; /// use hashbrown::{HashTable, DefaultHashBuilder}; - /// use std::hash::BuildHasher; /// /// let mut table = HashTable::new(); /// let hasher = DefaultHashBuilder::default(); @@ -580,7 +580,7 @@ where /// table.insert_unique(hasher(&3), (3, 'c'), |val| hasher(&val.0)); /// /// let index = table.find_bucket_index(hasher(&2), |val| val.0 == 2).unwrap(); - /// assert!(std::ptr::eq( + /// assert!(core::ptr::eq( /// table.get_bucket(index).unwrap(), /// unsafe { table.get_bucket_unchecked(index) }, /// )); @@ -603,8 +603,8 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { + /// use core::hash::BuildHasher; /// use hashbrown::{HashTable, DefaultHashBuilder}; - /// use std::hash::BuildHasher; /// /// let mut table = HashTable::new(); /// let hasher = DefaultHashBuilder::default(); @@ -647,8 +647,8 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { + /// use core::hash::BuildHasher; /// use hashbrown::{HashTable, DefaultHashBuilder}; - /// use std::hash::BuildHasher; /// /// let mut table = HashTable::new(); /// let hasher = DefaultHashBuilder::default(); @@ -658,7 +658,7 @@ where /// table.insert_unique(hasher(&3), (3, 'c'), |val| hasher(&val.0)); /// /// let index = table.find_bucket_index(hasher(&2), |val| val.0 == 2).unwrap(); - /// assert!(std::ptr::eq( + /// assert!(core::ptr::eq( /// table.get_bucket_mut(index).unwrap(), /// unsafe { table.get_bucket_unchecked_mut(index) }, /// )); @@ -685,8 +685,8 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { + /// use core::hash::BuildHasher; /// use hashbrown::{HashTable, DefaultHashBuilder}; - /// use std::hash::BuildHasher; /// /// let mut v = HashTable::new(); /// let hasher = DefaultHashBuilder::default(); @@ -718,8 +718,8 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { + /// use core::hash::BuildHasher; /// use hashbrown::{HashTable, DefaultHashBuilder}; - /// use std::hash::BuildHasher; /// /// let mut v = HashTable::new(); /// let hasher = DefaultHashBuilder::default(); @@ -749,8 +749,8 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { + /// use core::hash::BuildHasher; /// use hashbrown::{HashTable, DefaultHashBuilder}; - /// use std::hash::BuildHasher; /// /// let mut table = HashTable::with_capacity(100); /// let hasher = DefaultHashBuilder::default(); @@ -785,8 +785,8 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { + /// use core::hash::BuildHasher; /// use hashbrown::{HashTable, DefaultHashBuilder}; - /// use std::hash::BuildHasher; /// /// let mut table = HashTable::with_capacity(100); /// let hasher = DefaultHashBuilder::default(); @@ -828,8 +828,8 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { + /// use core::hash::BuildHasher; /// use hashbrown::{HashTable, DefaultHashBuilder}; - /// use std::hash::BuildHasher; /// /// let mut table: HashTable = HashTable::new(); /// let hasher = DefaultHashBuilder::default(); @@ -863,8 +863,8 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { + /// use core::hash::BuildHasher; /// use hashbrown::{HashTable, DefaultHashBuilder}; - /// use std::hash::BuildHasher; /// /// let mut table: HashTable = HashTable::new(); /// let hasher = DefaultHashBuilder::default(); @@ -897,8 +897,8 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { + /// use core::hash::BuildHasher; /// use hashbrown::{HashTable, DefaultHashBuilder}; - /// use std::hash::BuildHasher; /// /// let mut table = HashTable::new(); /// let hasher = DefaultHashBuilder::default(); @@ -944,8 +944,8 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { + /// use core::hash::BuildHasher; /// use hashbrown::{HashTable, DefaultHashBuilder}; - /// use std::hash::BuildHasher; /// /// let hasher = DefaultHashBuilder::default(); /// let hasher = |val: &_| hasher.hash_one(val); @@ -970,8 +970,8 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { + /// use core::hash::BuildHasher; /// use hashbrown::{HashTable, DefaultHashBuilder}; - /// use std::hash::BuildHasher; /// /// let hasher = DefaultHashBuilder::default(); /// let hasher = |val: &_| hasher.hash_one(val); @@ -997,8 +997,8 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { + /// use core::hash::BuildHasher; /// use hashbrown::{HashTable, DefaultHashBuilder}; - /// use std::hash::BuildHasher; /// /// let mut table = HashTable::new(); /// let hasher = DefaultHashBuilder::default(); @@ -1032,8 +1032,8 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { + /// use core::hash::BuildHasher; /// use hashbrown::{HashTable, DefaultHashBuilder}; - /// use std::hash::BuildHasher; /// /// let mut table = HashTable::new(); /// let hasher = DefaultHashBuilder::default(); @@ -1107,8 +1107,8 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { + /// use core::hash::BuildHasher; /// use hashbrown::{HashTable, DefaultHashBuilder}; - /// use std::hash::BuildHasher; /// /// let mut table = HashTable::new(); /// let hasher = DefaultHashBuilder::default(); @@ -1145,8 +1145,8 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { + /// use core::hash::BuildHasher; /// use hashbrown::{HashTable, DefaultHashBuilder}; - /// use std::hash::BuildHasher; /// /// let mut table = HashTable::new(); /// let hasher = DefaultHashBuilder::default(); @@ -1184,8 +1184,8 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { + /// use core::hash::BuildHasher; /// use hashbrown::{HashTable, DefaultHashBuilder}; - /// use std::hash::BuildHasher; /// /// let mut table = HashTable::new(); /// let hasher = DefaultHashBuilder::default(); @@ -1239,8 +1239,8 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { + /// use core::hash::BuildHasher; /// use hashbrown::{HashTable, DefaultHashBuilder}; - /// use std::hash::BuildHasher; /// /// let mut table = HashTable::new(); /// let hasher = DefaultHashBuilder::default(); @@ -1275,8 +1275,8 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { + /// use core::hash::BuildHasher; /// use hashbrown::{HashTable, DefaultHashBuilder}; - /// use std::hash::BuildHasher; /// /// let mut table = HashTable::new(); /// let hasher = DefaultHashBuilder::default(); @@ -1310,8 +1310,8 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { + /// use core::hash::BuildHasher; /// use hashbrown::{HashTable, DefaultHashBuilder}; - /// use std::hash::BuildHasher; /// /// let mut table = HashTable::new(); /// let hasher = DefaultHashBuilder::default(); @@ -1356,8 +1356,8 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { + /// use core::hash::BuildHasher; /// use hashbrown::{HashTable, DefaultHashBuilder}; - /// use std::hash::BuildHasher; /// /// let mut table = HashTable::new(); /// let hasher = DefaultHashBuilder::default(); @@ -1410,9 +1410,9 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { + /// use core::hash::BuildHasher; /// use hashbrown::hash_table::Entry; /// use hashbrown::{HashTable, DefaultHashBuilder}; - /// use std::hash::BuildHasher; /// /// let mut libraries: HashTable<(&str, u32)> = HashTable::new(); /// let hasher = DefaultHashBuilder::default(); @@ -1447,8 +1447,8 @@ where /// ```should_panic /// # #[cfg(feature = "nightly")] /// # fn test() { + /// # use core::hash::BuildHasher; /// # use hashbrown::{HashTable, DefaultHashBuilder}; - /// # use std::hash::BuildHasher; /// /// let mut libraries: HashTable<(&str, u32)> = HashTable::new(); /// let hasher = DefaultHashBuilder::default(); @@ -1512,9 +1512,9 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { + /// use core::hash::BuildHasher; /// use hashbrown::hash_table::Entry; /// use hashbrown::{HashTable, DefaultHashBuilder}; - /// use std::hash::BuildHasher; /// /// let mut libraries: HashTable<(&str, u32)> = HashTable::new(); /// let hasher = DefaultHashBuilder::default(); @@ -1661,9 +1661,9 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { +/// use core::hash::BuildHasher; /// use hashbrown::hash_table::{Entry, OccupiedEntry}; /// use hashbrown::{HashTable, DefaultHashBuilder}; -/// use std::hash::BuildHasher; /// /// let mut table = HashTable::new(); /// let hasher = DefaultHashBuilder::default(); @@ -1713,9 +1713,9 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { + /// use core::hash::BuildHasher; /// use hashbrown::hash_table::{Entry, OccupiedEntry}; /// use hashbrown::{HashTable, DefaultHashBuilder}; - /// use std::hash::BuildHasher; /// /// let mut table = HashTable::new(); /// let hasher = DefaultHashBuilder::default(); @@ -1743,9 +1743,9 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { + /// use core::hash::BuildHasher; /// use hashbrown::hash_table::{Entry, OccupiedEntry}; /// use hashbrown::{HashTable, DefaultHashBuilder}; - /// use std::hash::BuildHasher; /// /// let mut table = HashTable::<&str>::new(); /// let hasher = DefaultHashBuilder::default(); @@ -1785,8 +1785,8 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { + /// use core::hash::BuildHasher; /// use hashbrown::{HashTable, DefaultHashBuilder}; - /// use std::hash::BuildHasher; /// /// let mut table: HashTable<&str> = HashTable::new(); /// let hasher = DefaultHashBuilder::default(); @@ -1822,8 +1822,8 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { + /// use core::hash::BuildHasher; /// use hashbrown::{HashTable, DefaultHashBuilder}; - /// use std::hash::BuildHasher; /// /// let mut table: HashTable<&str> = HashTable::new(); /// let hasher = DefaultHashBuilder::default(); @@ -1867,8 +1867,8 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { + /// use core::hash::BuildHasher; /// use hashbrown::{HashTable, DefaultHashBuilder}; - /// use std::hash::BuildHasher; /// /// let mut table: HashTable = HashTable::new(); /// let hasher = DefaultHashBuilder::default(); @@ -1902,8 +1902,8 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { + /// use core::hash::BuildHasher; /// use hashbrown::{HashTable, DefaultHashBuilder}; - /// use std::hash::BuildHasher; /// /// let mut table: HashTable<(&str, u32)> = HashTable::new(); /// let hasher = DefaultHashBuilder::default(); @@ -1967,9 +1967,9 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { +/// use core::hash::BuildHasher; /// use hashbrown::hash_table::{Entry, OccupiedEntry}; /// use hashbrown::{HashTable, DefaultHashBuilder}; -/// use std::hash::BuildHasher; /// /// let mut table = HashTable::new(); /// let hasher = DefaultHashBuilder::default(); @@ -2049,9 +2049,9 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { + /// use core::hash::BuildHasher; /// use hashbrown::hash_table::Entry; /// use hashbrown::{HashTable, DefaultHashBuilder}; - /// use std::hash::BuildHasher; /// /// let mut table: HashTable<&str> = HashTable::new(); /// let hasher = DefaultHashBuilder::default(); @@ -2097,9 +2097,9 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { + /// use core::hash::BuildHasher; /// use hashbrown::hash_table::Entry; /// use hashbrown::{HashTable, DefaultHashBuilder}; - /// use std::hash::BuildHasher; /// /// let mut table: HashTable<&str> = HashTable::new(); /// let hasher = DefaultHashBuilder::default(); @@ -2133,9 +2133,9 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { + /// use core::hash::BuildHasher; /// use hashbrown::hash_table::Entry; /// use hashbrown::{HashTable, DefaultHashBuilder}; - /// use std::hash::BuildHasher; /// /// let mut table: HashTable<(&str, u32)> = HashTable::new(); /// let hasher = DefaultHashBuilder::default(); @@ -2186,9 +2186,9 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { + /// use core::hash::BuildHasher; /// use hashbrown::hash_table::Entry; /// use hashbrown::{HashTable, DefaultHashBuilder}; - /// use std::hash::BuildHasher; /// /// let mut table: HashTable<(&str, u32)> = HashTable::new(); /// let hasher = DefaultHashBuilder::default(); @@ -2245,8 +2245,8 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { + /// use core::hash::BuildHasher; /// use hashbrown::{HashTable, DefaultHashBuilder}; - /// use std::hash::BuildHasher; /// /// let mut table = HashTable::new(); /// let hasher = DefaultHashBuilder::default(); @@ -2288,9 +2288,9 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { + /// use core::hash::BuildHasher; /// use hashbrown::{HashTable, DefaultHashBuilder}; /// use hashbrown::hash_table::Entry; - /// use std::hash::BuildHasher; /// /// let mut table = HashTable::new(); /// let hasher = DefaultHashBuilder::default(); @@ -2360,9 +2360,9 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { +/// use core::hash::BuildHasher; /// use hashbrown::hash_table::{Entry, VacantEntry}; /// use hashbrown::{HashTable, DefaultHashBuilder}; -/// use std::hash::BuildHasher; /// /// let mut table: HashTable<&str> = HashTable::new(); /// let hasher = DefaultHashBuilder::default(); @@ -2418,9 +2418,9 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { + /// use core::hash::BuildHasher; /// use hashbrown::hash_table::Entry; /// use hashbrown::{HashTable, DefaultHashBuilder}; - /// use std::hash::BuildHasher; /// /// let mut table: HashTable<&str> = HashTable::new(); /// let hasher = DefaultHashBuilder::default(); @@ -2473,9 +2473,9 @@ where /// ``` /// # #[cfg(feature = "nightly")] /// # fn test() { +/// use core::hash::BuildHasher; /// use hashbrown::hash_table::{AbsentEntry, Entry}; /// use hashbrown::{HashTable, DefaultHashBuilder}; -/// use std::hash::BuildHasher; /// /// let mut table: HashTable<&str> = HashTable::new(); /// let hasher = DefaultHashBuilder::default(); diff --git a/tests/equivalent_trait.rs b/tests/equivalent_trait.rs index 31f0a63e2..5573cab28 100644 --- a/tests/equivalent_trait.rs +++ b/tests/equivalent_trait.rs @@ -3,7 +3,7 @@ use hashbrown::Equivalent; use hashbrown::HashMap; -use std::hash::Hash; +use core::hash::Hash; #[derive(Debug, Hash)] pub struct Pair(pub A, pub B); diff --git a/tests/hasher.rs b/tests/hasher.rs index 223737844..733cbf5a1 100644 --- a/tests/hasher.rs +++ b/tests/hasher.rs @@ -2,8 +2,8 @@ #![cfg(not(miri))] // FIXME: takes too long +use core::hash::{BuildHasher, BuildHasherDefault, Hasher}; use hashbrown::HashSet; -use std::hash::{BuildHasher, BuildHasherDefault, Hasher}; fn check() { let range = 0..1_000; @@ -29,7 +29,7 @@ fn default() { /// Use std's default hasher. #[test] fn random_state() { - check::(); + check::(); } /// Use a constant 0 hash. diff --git a/tests/hasher_unwind.rs b/tests/hasher_unwind.rs index ce8012731..9bf5ab23f 100644 --- a/tests/hasher_unwind.rs +++ b/tests/hasher_unwind.rs @@ -9,14 +9,15 @@ //! lookups can no longer find the original keys and iteration starts yielding //! repeated garbage-like entries. -use hashbrown::HashMap; -use std::collections::BTreeSet; -use std::{ +use core::{ hash::{BuildHasher, Hash, Hasher}, - panic::{AssertUnwindSafe, catch_unwind}, - sync::Mutex, + panic::AssertUnwindSafe, sync::atomic::{AtomicUsize, Ordering}, }; +use hashbrown::HashMap; +use std::collections::BTreeSet; +use std::panic::catch_unwind; +use std::sync::Mutex; /// One-shot panic switch used to trigger the first `build_hasher` call that /// occurs inside `reserve(1)`. diff --git a/tests/set.rs b/tests/set.rs index 2fa13c128..bb26ce0f3 100644 --- a/tests/set.rs +++ b/tests/set.rs @@ -1,9 +1,9 @@ #![expect(missing_docs)] // https://github.com/rust-lang/rust/issues/137561 #![cfg(not(miri))] // FIXME: takes too long +use core::iter; use hashbrown::HashSet; use rand::{Rng, SeedableRng, distr::Alphanumeric, rngs::SmallRng}; -use std::iter; #[test] fn test_hashset_insert_remove() {