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
The implementation of HashSet::get_or_insert_with is not good. This method make it quite easy to break the invariant of set that all elements are repeated in set only once. Let's say this test passes:
The text was updated successfully, but these errors were encountered:
JustForFun88
changed the title
Violating the set invariant with HashSet::get or_insert_with
Violating the set invariant with HashSet::get_or_insert_withFeb 15, 2023
There is a much longer discussion about this in rust-lang/rust#60896, which is about the equivalent (unstable) method in the standard library. I would prefer to keep the API as it is for now until a decision is made on that issue. One proposed alternative is to drop this function and instead only provide get_or_insert_owned.
There is a much longer discussion about this in rust-lang/rust#60896, which is about the equivalent (unstable) method in the standard library. I would prefer to keep the API as it is for now until a decision is made on that issue. One proposed alternative is to drop this function and instead only provide get_or_insert_owned.
Didn't know about the discussion. In any case, I'll leave #400 open for now, pending a final decision.
The implementation of
HashSet::get_or_insert_with
is not good. This method make it quite easy to break the invariant of set that all elements are repeated in set only once. Let's say this test passes:May be we need document it?
The text was updated successfully, but these errors were encountered: