Rust: Tracking issue for HashMap::drain_filter and HashSet::drain_filter (hash_drain_filter)

Created on 1 Apr 2019  路  4Comments  路  Source: rust-lang/rust

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 https://github.com/rust-lang/rfcs/issues/2140

A-collections C-feature-request T-libs

Most helpful comment

All 4 comments

This may be easy to implement since drain_filter was added to the underlying hashbrown types in rust-lang/hashbrown#135 and rust-lang/hashbrown#179. (Requires hashbrown 0.8.1 or later; see #70052.)

I have implemented this on a branch, but it will need to wait for a new release of the hashbrown crate because it depends on rust-lang/hashbrown#185, rust-lang/hashbrown#187, and rust-lang/hashbrown#188:

https://github.com/rust-lang/rust/compare/master...mbrubeck:hash_drain_filter

Was this page helpful?
0 / 5 - 0 ratings