Remove HashSet::get_or_insert_with#123657
Conversation
|
rustbot has assigned @Mark-Simulacrum. Use |
|
r=me, but I don't think we should say this is unsound? The method is entirely safe code so that implies other problems. It might be a bad idea, but that's a different kind of problem than a soundness issue. |
This comment has been minimized.
This comment has been minimized.
This method is unsound because it allows inserting a key at the "wrong" position in a `HashSet`, which could result in it not appearing it future lookups or being inserted multiple times in the set. Instead, `HashSet::get_or_insert` and `HashSet::get_or_insert_owned` should be preferred.
24b7e97 to
8d5e8b2
Compare
|
The view of the libs-api team is that unsafe code should be able to rely on an incoming |
|
I agree that we want that reliability, but the term "unsound" is the other way around:
|
|
wouldn't it make more sense to |
|
Sure, adding a check on the new value might be better than throwing this API out altogether... |
Then So either both |
Does it? If we're considering malicious impls, then your |
|
Closing since |
This method is unsound because it allows inserting a key at the "wrong" position in a
HashSet, which could result in it not appearing it future lookups or being inserted multiple times in the set.Instead,
HashSet::get_or_insertandHashSet::get_or_insert_ownedshould be preferred.