From 33e7c87dfc6dba1c22080f3bfa334830c667ef2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20P=C3=A9rez=20Garc=C3=ADa?= Date: Thu, 5 Dec 2019 21:19:02 -0600 Subject: [PATCH] Adding example to docs --- src/future/future/mod.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/future/future/mod.rs b/src/future/future/mod.rs index 569d0320..efa832a7 100644 --- a/src/future/future/mod.rs +++ b/src/future/future/mod.rs @@ -360,6 +360,21 @@ extension_trait! { #[doc = r#" Waits for both the future and a timeout, if the timeout completes before the future, it returns an TimeoutError. + + # Example + ``` + #async_std::task::block_on(async { + let fut = future::ready(0); + let dur = Duration::from_millis(100); + let res = fut.timeout(dur).await; + assert!(res.is_ok()); + + let fut = future::ready(0); + let dur = Duration::from_millis(100); + let res = fut.timeout(dur).await; + assert!(res.is_ok()) + # }); + ``` "#] #[cfg(any(feature = "unstable", feature = "docs"))] #[cfg_attr(feature = "docs", doc(cfg(unstable)))]