3 ms·
> unindexable NaN keys that just sit in your hashmap forever. Although you shouldn't put nonsense in a HashMap, HashMap::drain will give you (an iterator to ge
by tialaramex 8mo ago
> unindexable NaN keys that just sit in your hashmap forever.
Although you shouldn't put nonsense in a HashMap, HashMap::drain will give you (an iterator to get) back everything you put into the HashMap even if it's nonsense and HashMap::retain will let you provide a predicate to throw away the nonsense if you want to keep everything else, while HashMap::extract_if even allows you to get the nonsense back out again to put that somewhere more sensible.
These work because they don't need to find your nonsense in particular using hashing, which may now be impossible, they're just looking at everything.