Add IntoStream for all Iterator<_> - #3106
Closed
matthiasbeyer wants to merge 1 commit into
Closed
matthiasbeyer wants to merge 1 commit into
matthiasbeyer wants to merge 1 commit into
Conversation
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
taiki-e
reviewed
Nov 7, 2020
Member
There was a problem hiding this comment.
Thanks for the PR. I think this PR's approach has some issues:
- APIs that allow all iterators to be used as streams unconditionally without additional annotations may not be preferable, as iterators may block threads.
- If you adopt the name
IntoStream, for consistency withIntoIterator/IntoFuture, it preferable to be implemented in all streams, not all iterators. (And implementIntoStreamfor some iterators/collections) - If implement
IntoStreamfor all streams, sinceStreamis an upstream crate (futures-core)'s trait, addingIntoStreamin a downstream crate (tokio) has some limitations. (see async-rs/async-std#213 and rust-lang/futures-rs#1879) (In this case, I recommend doing in upstream)
Member
|
This should probably go in the futures crate, modulo @taiki-e's concerns. |
Contributor
Author
|
Okay, thanks for your time! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
I just started recently using tokio (or writing async-await rust), and I found it very inconvenient (and slightly harder to read) to write
But instead I wanted to write
Which is the problem I try to solve with this PR.
Solution
This PR thus implements an extension trait for all
std::iter::Iterators which adds theinto_stream()conveniance function.Note
Please note that this is my first PR to this project and although I've read the contribution guidelines, I want to apologize in advance for any mistakes made.
Thank you for this awesome library!