Skip to content

Commit f53fcbb

Browse files
committed
test,docs: Add stream::pending example code
1 parent e9357c0 commit f53fcbb

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Diff for: src/stream/pending.rs

+21
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,27 @@ pub struct Pending<T> {
1818
/// Creates a stream that never returns any items.
1919
///
2020
/// The returned stream will always return `Pending` when polled.
21+
/// # Examples
22+
///
23+
/// ```
24+
/// # async_std::task::block_on(async {
25+
/// #
26+
/// use std::time::Duration;
27+
///
28+
/// use async_std::prelude::*;
29+
/// use async_std::stream;
30+
///
31+
/// let dur = Duration::from_millis(100);
32+
/// let mut s = stream::pending::<()>().timeout(dur);
33+
///
34+
/// let item = s.next().await;
35+
///
36+
/// assert!(item.is_some());
37+
/// assert!(item.unwrap().is_err());
38+
///
39+
/// #
40+
/// # })
41+
/// ```
2142
pub fn pending<T>() -> Pending<T> {
2243
Pending {
2344
_marker: PhantomData,

0 commit comments

Comments
 (0)