From f53fcbb7060390757b91edd1bc195ecc804be730 Mon Sep 17 00:00:00 2001 From: k-nasa Date: Tue, 14 Jan 2020 10:18:14 +0900 Subject: [PATCH] test,docs: Add stream::pending example code --- src/stream/pending.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/stream/pending.rs b/src/stream/pending.rs index 5563d30..922a540 100644 --- a/src/stream/pending.rs +++ b/src/stream/pending.rs @@ -18,6 +18,27 @@ pub struct Pending { /// Creates a stream that never returns any items. /// /// The returned stream will always return `Pending` when polled. +/// # Examples +/// +/// ``` +/// # async_std::task::block_on(async { +/// # +/// use std::time::Duration; +/// +/// use async_std::prelude::*; +/// use async_std::stream; +/// +/// let dur = Duration::from_millis(100); +/// let mut s = stream::pending::<()>().timeout(dur); +/// +/// let item = s.next().await; +/// +/// assert!(item.is_some()); +/// assert!(item.unwrap().is_err()); +/// +/// # +/// # }) +/// ``` pub fn pending() -> Pending { Pending { _marker: PhantomData,