Skip to content

Commit 5e8d1e6

Browse files
committed
stream: correct iterators in doc examples
Correct the iterators used in examples to produce the described output.
1 parent f4b8c7a commit 5e8d1e6

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/stream/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@
164164
//! #
165165
//! # use async_std::prelude::*;
166166
//! # use async_std::stream;
167-
//! let mut values = stream::repeat(1u8).take(5);
167+
//! let mut values = stream::from_iter(1u8..6);
168168
//!
169169
//! while let Some(x) = values.next().await {
170170
//! println!("{}", x);
@@ -183,7 +183,8 @@
183183
//!
184184
//! Unlike `std::iter::IntoIterator`, `IntoStream` does not have compiler
185185
//! support yet. This means that automatic conversions like with `for` loops
186-
//! doesn't occur yet, and `into_stream` will always have to be called manually.
186+
//! doesn't occur yet, and `into_stream` or `from_iter` as above will always
187+
//! have to be called manually.
187188
//!
188189
//! [`IntoStream`]: trait.IntoStream.html
189190
//! [`into_stream`]: trait.IntoStream.html#tymethod.into_stream
@@ -271,7 +272,7 @@
271272
//! #
272273
//! # use async_std::prelude::*;
273274
//! # use async_std::stream;
274-
//! let numbers = stream::repeat(1u8);
275+
//! let numbers = stream::from_iter(0u8..);
275276
//! let mut five_numbers = numbers.take(5);
276277
//!
277278
//! while let Some(number) = five_numbers.next().await {

0 commit comments

Comments
 (0)