Added
-
from_iter_uniqueconstructors onIdHashMap,BiHashMap, andTriHashMap, matching the existingIdOrdMap::from_iter_unique. These build a map from an iterator and, rather than overwriting, return an error on the first item that conflicts with an already-inserted one.Because a value in a
BiHashMaporTriHashMapcan conflict on more than one key at once, the error reports every distinct existing item it collides with (up to two forBiHashMapand up to three forTriHashMap).
Changed
- MSRV updated to Rust 1.86.
Fixed
-
Deserialization no longer preallocates based on an unbounded size hint. Length-prefixed formats such as bincode and postcard derive their size hint from the input, so a small hostile payload claiming a huge number of elements could previously cause an excessively large allocation before any element was read. Preallocation is now capped at 1 MiB worth of items, matching what
serdedoes for the standard library's collections. -
The
insert_overwritepath onIdHashMapno longer aborts when an allocation fails, matching the existing guarantee onBiHashMapandTriHashMap. Instead, it results in a catchable panic. (The map is left unchanged, similar toBiHashMapandTriHashMap.)Note that
BTreeMap::insert_overwritewill abort on allocation failure, because it calls intostdwhich doesn't have an equivalent toHashMap::try_reserve.
Other improvements
- The insert paths now do fewer redundant checks for duplicates. Thanks izuzak for your first contribution!