From 5e8d1e6e83b99754444173095246b620af4aa06b Mon Sep 17 00:00:00 2001 From: Dmitry S Date: Sun, 7 Nov 2021 21:12:01 +0100 Subject: [PATCH] stream: correct iterators in doc examples Correct the iterators used in examples to produce the described output. --- src/stream/mod.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/stream/mod.rs b/src/stream/mod.rs index b3c7ff7a..f7f2727a 100644 --- a/src/stream/mod.rs +++ b/src/stream/mod.rs @@ -164,7 +164,7 @@ //! # //! # use async_std::prelude::*; //! # use async_std::stream; -//! let mut values = stream::repeat(1u8).take(5); +//! let mut values = stream::from_iter(1u8..6); //! //! while let Some(x) = values.next().await { //! println!("{}", x); @@ -183,7 +183,8 @@ //! //! Unlike `std::iter::IntoIterator`, `IntoStream` does not have compiler //! support yet. This means that automatic conversions like with `for` loops -//! doesn't occur yet, and `into_stream` will always have to be called manually. +//! doesn't occur yet, and `into_stream` or `from_iter` as above will always +//! have to be called manually. //! //! [`IntoStream`]: trait.IntoStream.html //! [`into_stream`]: trait.IntoStream.html#tymethod.into_stream @@ -271,7 +272,7 @@ //! # //! # use async_std::prelude::*; //! # use async_std::stream; -//! let numbers = stream::repeat(1u8); +//! let numbers = stream::from_iter(0u8..); //! let mut five_numbers = numbers.take(5); //! //! while let Some(number) = five_numbers.next().await {