Implement Drain and IntoIterator
- Dominant language
- Rust
- Stars
- 580
- Forks
- 50
- PR merge metrics
- No merged PRs in 30d
Description
We should implement the `Drain` and `IntoIterator` traits on `HashMap`!
Part of what is tricky about `Drain` is the contract for what happens when the user "does something weird". For example, what happens if I write the following code:
```rust
std::mem::forget(map.drain());
```
Is `map` now empty or full? What happens if I read _one_ element and then drop the `Drain`? Take a look at [`hashbrown::RawDrain`](https://github.com/rust-lang/hashbrown/blob/6f5826ed934a5e6342681c27618bea71f9b0c800/src/raw/mod.rs#L1339) for some inspiration. I'm genuinely not sure what the best way to express this is a concurrent map.
@soruh began an implementation in #33, but it has since run out of time to work on it. It may still be useful to draw inspiration from though, and has a fair amount of good discussion around the challenges involved.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reading the discussion and partial implementation in #33, then compare its constraints with hashbrown::RawDrain. Work out and document the intended behavior for forgotten drains, partial consumption, and dropping Drain; done means HashMap supports Drain and IntoIterator with those semantics established.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100