Merge pull request #675 from k-nasa/add_timeout_example

Add stream::timeout example when timeout error
split-by-pattern
Florian Gilcher 5 years ago committed by GitHub
commit 84fe94444b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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…
Cancel
Save