Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Breaking Change] Headers' IntoIterator should return a tuple (HeaderName, T) rather than T #585

Closed
ConsoleTVs opened this issue Jan 26, 2023 · 0 comments

Comments

@ConsoleTVs
Copy link

Right now, the implementation for the trait IntoIterator for HeaderMap is:

impl<T> IntoIterator for HeaderMap<T> {
    type Item = (Option<HeaderName>, T);
    type IntoIter = IntoIter<T>;

    fn into_iter(self) -> IntoIter<T> { ... }
}

This does not allow to iterate over (header, value) pairs and is missleading since Both Item and IntoIter types are unused.

I propose to change this implementation to something along those lines:

impl<T> IntoIterator for HeaderMap<T> {
    type Item = (HeaderName, T);
    type IntoIter = IntoIter<Self::Item>;

    fn into_iter(self) -> Self::IntoIter { ... }
}

With the changes to this, iterations should be way easier now:

for (header, value) in headers {
  // header: HeaderName
  // value: T
}
@ConsoleTVs ConsoleTVs changed the title Headers' IntoIterator should return a tuple (HeaderName, T) rather than T [Breaking Change] Headers' IntoIterator should return a tuple (HeaderName, T) rather than T Jan 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant