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 {
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(()) }) }
```