Skip to content

Commit

Permalink
chore(*): finalize SCC 2.2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
wvwwvwwv committed Nov 15, 2024
1 parent 7dc282c commit 99032a0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 13 additions & 1 deletion src/hash_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ where
/// let hashcache: HashCache<u64, u32, RandomState> = 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),
Expand All @@ -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.
Expand Down
11 changes: 11 additions & 0 deletions src/hash_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit 99032a0

Please sign in to comment.