A feature request: implement `retain` on HeaderMap
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1.4k
- Forks
- 378
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 5
Description
It would be really handy to have the retain method available (as per std::collections) in order to allow headers to be removed based upon a closure. This would, for example, avoid the double-scan and "clone key" issues when one has a list of headers that must be retained or removed:
let delete_list: Vec<HeaderName> = headers
.keys()
.filter(|k| !allowed_headers.contains(*k))
.map(|k| k.clone())
.collect::<Vec<HeaderName>>();
for header in delete_list {
headers.remove(header);
}
would be replaced with
headers.retain(|(k,v)| allowed_headers.contains(*k));
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the HeaderMap implementation and its existing mutation-method tests, then read how closures are used by nearby APIs. Add the requested retain behavior for filtering header entries and cover both retained and removed headers in tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- api
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100