Skip to content

drain_filter has opposite behavior of standard library version #186

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
mbrubeck opened this issue Aug 10, 2020 · 1 comment · Fixed by #187
Closed

drain_filter has opposite behavior of standard library version #186

mbrubeck opened this issue Aug 10, 2020 · 1 comment · Fixed by #187

Comments

@mbrubeck
Copy link
Contributor

mbrubeck commented Aug 10, 2020

In methods like std::vec::Vec::drain_filter, the element is removed if the closure returns true. But in hashbrown::HashMap::drain_filter (#135) and hashbrown::HashSet::drain_filter (#179), the element is removed if the closure returns false. 😦

cc rust-lang/rust#59618


Update: This is fixed in hashbrown 0.9.0. When upgrading from earlier versions, all callers must flip the meaning of the predicate passed to the drain_filter method. I have submitted pull requests to all the affected crates I could find.

@Amanieu
Copy link
Member

Amanieu commented Aug 10, 2020

That... seems unfortunate. I assume the proper behavior is the one in libstd and the behavior of hashbrown is incorrect.

This is going to have to be a (silent) breaking change, but that's fine since we can just do a major version bump.

mbrubeck added a commit to mbrubeck/hashbrown that referenced this issue Aug 11, 2020
bors added a commit that referenced this issue Aug 11, 2020
Reverse `drain_filter` behavior to match libstd

Fixes #186.  This is the worst sort of silent breaking change, but we don't have much choice here.
bors added a commit that referenced this issue Aug 11, 2020
Reverse `drain_filter` behavior to match libstd

Fixes #186.  This is the worst sort of silent breaking change, but we don't have much choice here.
mbrubeck added a commit to mbrubeck/hashbrown that referenced this issue Aug 11, 2020
bors added a commit that referenced this issue Aug 11, 2020
Reverse `drain_filter` behavior to match libstd

Fixes #186.  This is the worst sort of silent breaking change, but we don't have much choice here.
bors added a commit that referenced this issue Aug 12, 2020
Reverse `drain_filter` behavior to match libstd

Fixes #186.  This is the worst sort of silent breaking change, but we don't have much choice here.
@bors bors closed this as completed in 7654023 Aug 12, 2020
mbrubeck added a commit to mbrubeck/ya-net-p2p that referenced this issue Sep 3, 2020
The behavior of the `HashMap::drain_filter` method has changed in this
release.  For details, see:

rust-lang/hashbrown#186
mbrubeck added a commit to mbrubeck/sorbus that referenced this issue Sep 3, 2020
The behavior of `drain_filter` has changed in this release:

rust-lang/hashbrown#186
mbrubeck added a commit to mbrubeck/lol-html that referenced this issue Sep 3, 2020
The behavior of the `drain_filter` method has changed in this release:

rust-lang/hashbrown#186
mbrubeck added a commit to mbrubeck/satsuma that referenced this issue Sep 3, 2020
The behavior of `drain_filter` has changed in this release:

rust-lang/hashbrown#186
mbrubeck added a commit to mbrubeck/redshirt that referenced this issue Sep 3, 2020
The behavior of `drain_filter` has changed in this release:

rust-lang/hashbrown#186
bors bot added a commit to CAD97/sorbus that referenced this issue Sep 4, 2020
72: Update to hashbrown 0.9 r=CAD97 a=mbrubeck

The behavior of `drain_filter` has changed in this release:

rust-lang/hashbrown#186

Co-authored-by: Matt Brubeck <mbrubeck@limpet.net>
tomaka pushed a commit to tomaka/redshirt that referenced this issue Sep 4, 2020
The behavior of `drain_filter` has changed in this release:

rust-lang/hashbrown#186
inikulin pushed a commit to cloudflare/lol-html that referenced this issue Oct 13, 2020
* Update to hashbrown 0.9

The behavior of the `drain_filter` method has changed in this release:

rust-lang/hashbrown#186

* Use HashMap::retain instead of drain_filter
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants