forked from mirror/async-std
docs: Add stream::timeout example when timeout error
This commit is contained in:
parent
133e30e6f6
commit
ee102dfc9e
1 changed files with 7 additions and 0 deletions
|
@ -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(()) }) }
|
||||
```
|
||||
|
|
Loading…
Reference in a new issue