-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Tracking issue for HashMap::extract_if and HashSet::extract_if #59618
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
Comments
Related #42849 |
This may be easy to implement since |
I have implemented this on a branch, but it will need to wait for a new release of the |
Add drain_filter method to HashMap and HashSet Add `HashMap::drain_filter` and `HashSet::drain_filter`, implementing part of rust-lang/rfcs#2140. These new methods are unstable. The tracking issue is rust-lang#59618. The added iterators behave the same as `BTreeMap::drain_filter` and `BTreeSet::drain_filter`, except their iteration order is arbitrary. The unit tests are adapted from `alloc::collections::btree`. This branch rewrites `HashSet` to be a wrapper around `hashbrown::HashSet` rather than `std::collections::HashMap`. (Both are themselves wrappers around `hashbrown::HashMap`, so the in-memory representation is the same either way.) This lets `std` re-use more iterator code from `hashbrown`. Without this change, we would need to duplicate much more code to implement `HashSet::drain_filter`. This branch also updates the `hashbrown` crate to version 0.9.0. Aside from changes related to the `DrainFilter` iterators, this version only changes features that are not used in libstd or rustc. And it updates `indexmap` to version 1.6.0, whose only change is compatibility with `hashbrown` 0.9.0.
This is now implemented in nightly behind the unstable |
Any reason not to stabilize this @mbrubeck? |
There are some open questions about naming and API design; see the summary in #43244 (comment) for some details. |
Is this ready for the FCP? |
On the companion But that could be discussed as part of the FCP. |
Would love to use this feature in stable! |
Let's see if we have consensus to stabilize these: @rfcbot merge |
Team member @joshtriplett has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. This will be merged soon. |
Rollup merge of rust-lang#134655 - GrigorenkoPV:hash_extract_if, r=cuviper Stabilize `hash_extract_if` FCP complete: rust-lang#59618 (comment) Tracking issue: rust-lang#59618 Closes rust-lang#59618
Stabilize `hash_extract_if` FCP complete: rust-lang/rust#59618 (comment) Tracking issue: #59618 Closes #59618
…viper Stabilize `hash_extract_if` FCP complete: rust-lang#59618 (comment) Tracking issue: rust-lang#59618 Closes rust-lang#59618
…viper Stabilize `hash_extract_if` FCP complete: rust-lang#59618 (comment) Tracking issue: rust-lang#59618 Closes rust-lang#59618
The feature gate for the issue is
#![feature(hash_extract_if)]
(previouslyhash_drain_filter
)Currently only Vec and LinkedList have a drain_filter method, while other collections such as HashMap and HashSet do not.
This means that currently, removing items from a collection, and getting ownership of those items is fairly...unidiomatic and cumbersome.
For references, see rust-lang/rfcs#2140
Implementation History
The text was updated successfully, but these errors were encountered: