Can't iterate `http::header::ValueDrain` non-destructively
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1.4k
- Forks
- 378
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 5
Description
I need to remove an entry from a HeaderMap and then iterate the removed values non-destructively. The reason for this is I need to mutate the HeaderMap while I'm processing the removed values, but I need to process the removed values as &[u8] or &str. Doing anything else will involve reallocating for every value (I need to trim off the front) and that should be unnecessary for what I'm doing. If HeaderValue exposed its inner Bytes representation then I could use that (as that is cheaply cloneable), but it doesn't, and so I can't.
The simplest solution here would be if http::header::ValueDrain supported iterating references to its values. I know it's already an iterator, but it could have an .iter(&self) method that returns an iterator that borrows the drain (and then &'_ ValueDrain could also implement IntoIterator to return that same borrowed iterator). This way I can work with references to the values, or iterate the values multiple times, without having to collect them into a separate allocation (such as a Vec).
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 implementation and iterator behavior for http::header::ValueDrain, then inspect how HeaderMap removal and HeaderValue access are represented. Done means a borrowed iteration path can expose removed values as references, support repeated iteration, and preserve the existing owning iterator behavior without requiring a collection.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100