weak-table
Weak hash maps and sets
0.4.0
4.3M downloads/mo
#4831 most downloaded on crates.io
tov/weak-table-rs
What this package is like to depend on
Last release 19 days ago
04 Aug 2026
Release timing varies
gaps range from 9 days to 4.6 years
Nearly every release is documented
notes for 12 of 13 stable releases
Nothing withdrawn
no release was ever pulled
8 years old
16 releases · first in 2018
4 releases in the last 12 months
see the full history below
Release timeline
16 releases · Mar 2018 to Aug 2026Releases
latest 16-
0.4.004 Aug 2026Release notes
Open source →This release improves performance and correctness by replacing the backend with [
hashbrown]. It also adds numerous APIs, and extensive tests.There are breaking changes in this release, but they should not affect most users. Notably, the
allocfeature has been removed, theahashfeature has been deprecated, and the minimum supported rust version for this crate has been increased to 1.65. See below for more details.Added
-
High-coverage unit tests for the hash table backend.
-
High-coverage unit tests for all maps and sets.
-
Property tests for all of the exposed map and set types.
-
Benchmarks based on
criterion. -
Added APIs to map types to match with stdlib
HashMap:extract_ifget_disjoint_mut,get_both_disjoint_mutinto_keysinto_valuesremove_entryshrink_totry_reserveFrom<[(K, V); N]>Entry::and_modifyEntry::insert_entryEntry::or_insert_with_keyVacantEntry::insert_entry.
-
Added APIs to set types to match with stdlib
HashSet:differenceextract_ifintersectionis_disjointis_supersetshrink_tosymmetric_differencetaketry_reserveunionBitAndBitOrBitXorFrom<[T;N]>Sub
-
It is now possible to build as
no_stdwithout ahash support. If you do, there will be no defaultBuildHasher, and thenew()andwith_capacity()methods will be absent.
Removed
- The non-functional
allocfeature has been removed.
Deprecated
- The
ahashfeature is now deprecated for security reasons. Instead, use the constructors that allow you to specify aBuildHashermanually.
Changed (visible)
- All hash-tables now use a new backend based on [
hashbrown] for improved speed and correctness. (Benchmarks report a speedup around 30-50%.) - The Minimum Supported Rust Version is now 1.65.
(This is necessary to use
hashbrownversion 0.16.) - The default capacity for new tables is now zero.
- Changed
load_factor()to return a value closer to the table's actual load factor. - Methods that do not require the element type to be WeakKey or WeakElement no longer constrain their parameters in this way.
- Constructors are now
#[must_use]. - ExtractIf iterators are now
#[must_use].
Changed (internal)
- Numerous Clippy warnings are now enabled.
- The Rust Edition is now 2021.
- We no longer rely on floating-point except in methods that return a floating-point result.
- The
Debugoutput is slightly different. - The source is now formatted according to the Rust style guide,
using
cargo fmt. - Allocation sizes are now slightly different.
- The output of
Debugis now slightly different. - Because of
hashbrowninternals, capacity calculations can behave differently. - Tests have been moved to a
testssubmodule, so that they can share code. - A great deal of common code has been extracted into macros, to avoid the risk of copy-and-paste errors.
- When
ahashis enabled, we now useahashversion 0.8.12 or later. - The
randdev-dependency has been removed.
Fixed
- The
retain()andremove_expired()methods no longer skip elements that changed position due to other elements having been removed. ([github#22]) - Fix a bug in
load_factor()calculation where it would returninffor a zero-capacity table. - Changed the output of Debug for
WeakHashSetandPtrWeakHashSet to display them as sets, not as maps to(). - Eliminated some possible integer overflows when trying to reserve very high capacities.
Documentation
- Cleaned up documentation that referred to sets as maps, or claimed that they had separate keys and values.
-
-
0.4.0-pre329 Jul 2026 pre-release -
0.4.0-pre218 Jul 2026 pre-releaseNothing published for this version
-
0.4.0-pre116 Jul 2026 pre-releaseNothing published for this version
-
0.3.201 Dec 2021 -
0.3.130 Nov 2021 -
0.3.027 Jun 2020 -
0.2.427 Jun 2020Release notes
Open source →Fixed
- Bad bucket selection on collision (h/t Andrew Browne
<[email protected]>).
- Bad bucket selection on collision (h/t Andrew Browne
-
0.2.330 May 2018 -
0.2.222 May 2018Release notes
Open source →Fixed
- Weak–weak submap operations were missing a line of code.
Added
{PtrWeakHashSet,PtrWeakKeyHashMap}::is_empty()methods.
-
0.2.122 May 2018 -
0.2.022 May 2018Release notes
Open source →Renamed
- from
WeakElement::expiredtoWeakElement::is_expired
Documention
- improved
- from
-
0.1.322 May 2018 -
0.1.221 May 2018Release notes
Open source →Added
WeakKeyHashMap::{get_key, get_both, get_both_mut}methodsWeakWeakHashMap::{get_key, get_both}methodsWeakHashSet::getmethod
Changed
- Values stored behind
Rcs can now be?Sized.
Removed
struct RcKey<K>
Documentation
- improved
-
0.1.105 Mar 2018 -
0.1.005 Mar 2018Nothing published for this version