From ee102dfc9e6d76593527524ecc36cfbbdb14f32d Mon Sep 17 00:00:00 2001 From: k-nasa Date: Wed, 15 Jan 2020 10:41:39 +0900 Subject: [PATCH] docs: Add stream::timeout example when timeout error --- src/stream/stream/mod.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/stream/stream/mod.rs b/src/stream/stream/mod.rs index 4cf88c7..6c84ac2 100644 --- a/src/stream/stream/mod.rs +++ b/src/stream/stream/mod.rs @@ -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(()) }) } ```