You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In case the entry already exists, it uses mem::replace() as you can see here (HashSet comes from the hashbrown crate and is in fact a HashMap without a value). But indeed, updating the docs to mention would be nice. Want to send a PR?
Location
https://doc.rust-lang.org/std/collections/struct.HashSet.html#method.insert
Summary
HashSet::insert
is underspecified.It says:
But when the set already contains a value, is existing value replaced with new, or new value just discarded?
It does not make difference for primitive types, but can have significant effect when inserting
Arc
for example.The text was updated successfully, but these errors were encountered: