Skip to content

Commit 84fe944

Browse files
authored
Merge pull request #675 from k-nasa/add_timeout_example
Add stream::timeout example when timeout error
2 parents cad2880 + ee102df commit 84fe944

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/stream/stream/mod.rs

+7
Original file line numberDiff line numberDiff line change
@@ -1645,6 +1645,13 @@ extension_trait! {
16451645
while let Some(v) = s.next().await {
16461646
assert_eq!(v, Ok(1));
16471647
}
1648+
1649+
// when timeout
1650+
let mut s = stream::pending::<()>().timeout(Duration::from_millis(10));
1651+
match s.next().await {
1652+
Some(item) => assert!(item.is_err()),
1653+
None => panic!()
1654+
};
16481655
#
16491656
# Ok(()) }) }
16501657
```

0 commit comments

Comments
 (0)