2
0
Fork 1
mirror of https://github.com/async-rs/async-std.git synced 2025-01-16 10:49:55 +00:00

docs: Add stream::timeout example when timeout error

This commit is contained in:
k-nasa 2020-01-15 10:41:39 +09:00
parent 133e30e6f6
commit ee102dfc9e

View file

@ -1645,6 +1645,13 @@ extension_trait! {
while let Some(v) = s.next().await { while let Some(v) = s.next().await {
assert_eq!(v, Ok(1)); assert_eq!(v, Ok(1));
} }
// when timeout
let mut s = stream::pending::<()>().timeout(Duration::from_millis(10));
match s.next().await {
Some(item) => assert!(item.is_err()),
None => panic!()
};
# #
# Ok(()) }) } # Ok(()) }) }
``` ```