diff options
Diffstat (limited to 'tokio/src/future.rs')
-rw-r--r-- | tokio/src/future.rs | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/tokio/src/future.rs b/tokio/src/future.rs index 3bc673d0..a2e4d220 100644 --- a/tokio/src/future.rs +++ b/tokio/src/future.rs @@ -40,20 +40,23 @@ pub trait FutureExt: Future { /// # Examples /// /// ``` + /// #![feature(async_await)] + /// /// use tokio::prelude::*; /// use std::time::Duration; - /// # use futures::future::{self, FutureResult}; /// - /// # fn long_future() -> FutureResult<(), ()> { - /// # future::ok(()) - /// # } - /// # - /// # fn main() { - /// let future = long_future() + /// async fn long_future() { + /// // do work here + /// } + /// + /// # async fn dox() { + /// let res = long_future() /// .timeout(Duration::from_secs(1)) - /// .map_err(|e| println!("error = {:?}", e)); + /// .await; /// - /// tokio::run(future); + /// if res.is_err() { + /// println!("operation timed out"); + /// } /// # } /// ``` #[cfg(feature = "timer")] |