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:
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 {
|
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(()) }) }
|
||||||
```
|
```
|
||||||
|
|
Loading…
Reference in a new issue