From 99032a0377a51198df0bdfa15b469db95c749997 Mon Sep 17 00:00:00 2001 From: Changgyoo Park Date: Fri, 15 Nov 2024 13:17:46 +0100 Subject: [PATCH] chore(*): finalize SCC 2.2.5 --- CHANGELOG.md | 1 + src/hash_cache.rs | 14 +++++++++++++- src/hash_index.rs | 11 +++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a41e4a7..3143674 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ 2.2.5 +* `Hash*::with_hasher` is now a const function: by [Daniel-Aaron-Bloom](https://github.com/Daniel-Aaron-Bloom). * Fix the `HashMap::upsert` document: by [dfaust](https://github.com/dfaust). 2.2.4 diff --git a/src/hash_cache.rs b/src/hash_cache.rs index 6e50410..98ca6b7 100644 --- a/src/hash_cache.rs +++ b/src/hash_cache.rs @@ -99,7 +99,7 @@ where /// let hashcache: HashCache = HashCache::with_hasher(RandomState::new()); /// ``` #[inline] - pub fn with_hasher(build_hasher: H) -> Self { + pub const fn with_hasher(build_hasher: H) -> Self { HashCache { array: AtomicShared::null(), minimum_capacity: AtomicUsize::new(0), @@ -108,6 +108,18 @@ where } } + /// Creates an empty [`HashCache`] with the given [`BuildHasher`]. + #[cfg(feature = "loom")] + #[inline] + pub fn with_hasher(build_hasher: H) -> Self { + Self { + array: AtomicShared::null(), + minimum_capacity: AtomicUsize::new(0), + maximum_capacity: DEFAULT_MAXIMUM_CAPACITY, + build_hasher, + } + } + /// Creates an empty [`HashCache`] with the specified capacity and [`BuildHasher`]. /// /// The actual capacity is equal to or greater than the specified capacity. diff --git a/src/hash_index.rs b/src/hash_index.rs index 0200289..0376250 100644 --- a/src/hash_index.rs +++ b/src/hash_index.rs @@ -126,6 +126,17 @@ where /// HashIndex::with_hasher(RandomState::new()); /// ``` #[inline] + pub const fn with_hasher(build_hasher: H) -> Self { + Self { + array: AtomicShared::null(), + minimum_capacity: AtomicUsize::new(0), + build_hasher, + } + } + + /// Creates an empty [`HashIndex`] with the given [`BuildHasher`]. + #[cfg(feature = "loom")] + #[inline] pub fn with_hasher(build_hasher: H) -> Self { Self { array: AtomicShared::null(),