From f1765108fb23569814b61c4bafd0aea401c0cdc2 Mon Sep 17 00:00:00 2001 From: Marko Mikulicic Date: Thu, 18 Feb 2021 18:46:42 +0100 Subject: [PATCH] doc: Sync interval.rs and time/mod.rs docs --- tokio/src/time/mod.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/tokio/src/time/mod.rs b/tokio/src/time/mod.rs index 8aaf9c18cc4..10407ba8232 100644 --- a/tokio/src/time/mod.rs +++ b/tokio/src/time/mod.rs @@ -54,12 +54,12 @@ //! # } //! ``` //! -//! A simple example using [`interval`] to execute a task every two seconds. +//! A simple example using `interval` to execute a task every two seconds. //! -//! The difference between [`interval`] and [`sleep`] is that an -//! [`interval`] measures the time since the last tick, which means that -//! `.tick().await` may wait for a shorter time than the duration specified -//! for the interval if some time has passed between calls to `.tick().await`. +//! The difference between `interval` and [`sleep`] is that an `interval` +//! measures the time since the last tick, which means that `.tick().await` +//! may wait for a shorter time than the duration specified for the interval +//! if some time has passed between calls to `.tick().await`. //! //! If the tick in the example below was replaced with [`sleep`], the task //! would only be executed once every three seconds, and not every two @@ -75,11 +75,9 @@ //! //! #[tokio::main] //! async fn main() { -//! let interval = time::interval(time::Duration::from_secs(2)); -//! tokio::pin!(interval); -//! +//! let mut interval = time::interval(time::Duration::from_secs(2)); //! for _i in 0..5 { -//! interval.as_mut().tick().await; +//! interval.tick().await; //! task_that_takes_a_second().await; //! } //! }