docs: Add stream::timeout example when timeout error

split-by-pattern
k-nasa 5 years ago
parent 133e30e6f6
commit ee102dfc9e

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