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

stream: impl FromIterator for StreamMap #4052

Merged
merged 2 commits into from Aug 24, 2021
Merged

stream: impl FromIterator for StreamMap #4052

merged 2 commits into from Aug 24, 2021

Conversation

nylonicious
Copy link
Contributor

@nylonicious nylonicious commented Aug 22, 2021

This allows to collect iterator into a StreamMap and to extend StreamMap with another one
Closes #3982.

Comment on lines 588 to 595
impl<K, V> IntoIterator for StreamMap<K, V> {
type Item = (K, V);
type IntoIter = std::vec::IntoIter<Self::Item>;

fn into_iter(self) -> Self::IntoIter {
self.entries.into_iter()
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementing IntoIterator for this type seems very confusing since it also implements Stream, but has a different item type as a Stream.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. I'm not sure if implementing Extend makes a lot of sense if StreamMap doesn't implement IntoIterator. I removed both Extend and IntoIterator impls if you feel like Extend makes sense I can add it back.

@Darksonn Darksonn added A-tokio-stream Area: The tokio-stream crate M-stream Module: tokio/stream labels Aug 22, 2021
Copy link
Contributor

@Darksonn Darksonn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

@Darksonn Darksonn merged commit 84f6845 into tokio-rs:master Aug 24, 2021
@Darksonn Darksonn changed the title stream: Impl {From, Into}Iterator, Extend for StreamMap stream: impl FromIterator for StreamMap Aug 24, 2021
@nylonicious nylonicious deleted the stream-map-impl branch August 25, 2021 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio-stream Area: The tokio-stream crate M-stream Module: tokio/stream
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement Extend and FromIterator for StreamMap
2 participants