From 54aaf3d0e30f0d352a54e11f8543d96a380e6469 Mon Sep 17 00:00:00 2001 From: Daria Sukhonina Date: Mon, 27 Feb 2023 17:17:31 +0300 Subject: [PATCH] time: document immediate completion guarantee for timeouts (#5509) --- tokio/src/time/timeout.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tokio/src/time/timeout.rs b/tokio/src/time/timeout.rs index 3bb98ea6f92..b6837360edc 100644 --- a/tokio/src/time/timeout.rs +++ b/tokio/src/time/timeout.rs @@ -28,6 +28,11 @@ use std::task::{self, Poll}; /// This function returns a future whose return type is [`Result`]``, where `T` is the /// return type of the provided future. /// +/// If the provided future completes immediatelly, then the future returned from +/// this function is guaranteed to complete immediatelly with an [`Ok`] variant +/// no matter the provided duration. +/// +/// [`Ok`]: std::result::Result::Ok /// [`Result`]: std::result::Result /// [`Elapsed`]: crate::time::error::Elapsed /// @@ -100,6 +105,11 @@ where /// This function returns a future whose return type is [`Result`]``, where `T` is the /// return type of the provided future. /// +/// If the provided future completes immediatelly, then the future returned from +/// this function is guaranteed to complete immediatelly with an [`Ok`] variant +/// no matter the provided deadline. +/// +/// [`Ok`]: std::result::Result::Ok /// [`Result`]: std::result::Result /// [`Elapsed`]: crate::time::error::Elapsed ///