stream: correct iterators in doc examples #997
Merged
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.
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 print1
five times instead - modified to usefrom_iter(1..6)
. Similarly, in the Iinfinity" section https://docs.rs/async-std/1.10.0/async_std/stream/index.html#infinity, changedstream::repeat(1u8)
tostream::from_iter(0u8)
to produce the described result, "print the numbers0
through4
".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, onlyasync_std::stream::Repeat
created withrepeat
- or a Stream in the modified example. AlsoIntoStream
is supported only on unstable - I wonder if it would be better to rename the section towhile let Loops and FromIter
and talk about conversion of iterators into streams withfrom_iter
instead ofinto_stream
.