forked from mirror/async-std
fixes example to resemble std more
This commit is contained in:
parent
ed944d051a
commit
2d75ffacc4
1 changed files with 7 additions and 8 deletions
|
@ -149,16 +149,15 @@ pub trait Stream {
|
||||||
/// # fn main() { async_std::task::block_on(async {
|
/// # fn main() { async_std::task::block_on(async {
|
||||||
/// #
|
/// #
|
||||||
/// use async_std::prelude::*;
|
/// use async_std::prelude::*;
|
||||||
/// use async_std::stream;
|
/// use std::collections::VecDeque;
|
||||||
///
|
///
|
||||||
/// let mut s = stream::repeat(9).take(4).enumerate();
|
/// let s: VecDeque<_> = vec!['a', 'b', 'c'].into_iter().collect();
|
||||||
/// let mut c: usize = 0;
|
/// let mut s = s.enumerate();
|
||||||
|
///
|
||||||
|
/// assert_eq!(s.next().await, Some((0, 'a')));
|
||||||
|
/// assert_eq!(s.next().await, Some((1, 'b')));
|
||||||
|
/// assert_eq!(s.next().await, Some((2, 'c')));
|
||||||
///
|
///
|
||||||
/// while let Some((i, v)) = s.next().await {
|
|
||||||
/// assert_eq!(c, i);
|
|
||||||
/// assert_eq!(v, 9);
|
|
||||||
/// c += 1;
|
|
||||||
/// }
|
|
||||||
/// #
|
/// #
|
||||||
/// # }) }
|
/// # }) }
|
||||||
fn enumerate(self) -> Enumerate<Self>
|
fn enumerate(self) -> Enumerate<Self>
|
||||||
|
|
Loading…
Reference in a new issue