Skip to content

stream: correct iterators in doc examples #997

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

Merged
merged 1 commit into from
Nov 10, 2021

Conversation

dmitris
Copy link
Contributor

@dmitris dmitris commented Nov 7, 2021

Correct the iterators used in examples to produce the described output.

Currently in https://docs.rs/async-std/1.10.0/async_std/stream/index.html#while-let-loops-and-intostream the text after the code snippet says "This will print the numbers one through five" but because the code uses stream::repeat(1u8).take(5), it will print 1 five times instead - modified to use from_iter(1..6). Similarly, in the Iinfinity" section https://docs.rs/async-std/1.10.0/async_std/stream/index.html#infinity, changed stream::repeat(1u8) to stream::from_iter(0u8) to produce the described result, "print the numbers 0 through 4".

I believe the Section "while let Loops and IntoStream" https://docs.rs/async-std/1.10.0/async_std/stream/index.html#while-let-loops-and-intostream has more problems. Is the into_stream used in this example? The explanation says: "we never called anything on our vector to produce a stream" - but as far as I see, there is no vector in the example, only async_std::stream::Repeat created with repeat - or a Stream in the modified example. Also IntoStream is supported only on unstable - I wonder if it would be better to rename the section to while let Loops and FromIter and talk about conversion of iterators into streams with from_iter instead of into_stream.

Correct the iterators used in examples to produce
the described output.
@dmitris
Copy link
Contributor Author

dmitris commented Nov 9, 2021

@yoshuawuyts would appreciate if you could review the suggested change, or point out someone who could do it. Thanks!

Copy link
Contributor

@yoshuawuyts yoshuawuyts left a comment

Choose a reason for hiding this comment

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

Looks good; thanks

@yoshuawuyts yoshuawuyts merged commit 69bb5cf into async-rs:master Nov 10, 2021
@dmitris dmitris deleted the fixdoc branch November 10, 2021 17:03
@dmitris
Copy link
Contributor Author

dmitris commented Nov 10, 2021

thanks @yoshuawuyts!

When will it make its way to https://docs.rs - after the next crate release?

Do you agree with the idea of changing the section header "while let Loops and IntoStream" to "while let Loops and FromIter" and talking about from_iter() instead of (or in addition to) into_stream? I can raise a PR if that sounds right in principle.

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

Successfully merging this pull request may close these issues.

2 participants