2
0
Fork 1
mirror of https://github.com/async-rs/async-std.git synced 2025-01-30 01:05:31 +00:00

Merge pull request #675 from k-nasa/add_timeout_example

Add stream::timeout example when timeout error
This commit is contained in:
Florian Gilcher 2020-01-21 16:02:28 +01:00 committed by GitHub
commit 84fe94444b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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