From 564a1b3c1ae5df7e3b1fec5df60ae802c89a73c8 Mon Sep 17 00:00:00 2001 From: Alex Butler Date: Fri, 28 Jun 2024 13:15:24 +0100 Subject: [PATCH] timeout, timeout_at support IntoFuture Bump msrv to 1.64 --- .github/workflows/ci.yml | 2 +- tokio-macros/Cargo.toml | 2 +- tokio-stream/Cargo.toml | 2 +- tokio-test/Cargo.toml | 2 +- tokio-util/Cargo.toml | 2 +- tokio/Cargo.toml | 2 +- tokio/src/time/timeout.rs | 14 +++++++------- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 76151902576..621f9da71e8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,7 @@ env: # - tokio-util/Cargo.toml # - tokio-test/Cargo.toml # - tokio-stream/Cargo.toml - rust_min: '1.63' + rust_min: '1.64' defaults: run: diff --git a/tokio-macros/Cargo.toml b/tokio-macros/Cargo.toml index c150334880c..28531e491e1 100644 --- a/tokio-macros/Cargo.toml +++ b/tokio-macros/Cargo.toml @@ -6,7 +6,7 @@ name = "tokio-macros" # - Create "tokio-macros-1.x.y" git tag. version = "2.3.0" edition = "2021" -rust-version = "1.63" +rust-version = "1.64" authors = ["Tokio Contributors "] license = "MIT" repository = "https://github.com/tokio-rs/tokio" diff --git a/tokio-stream/Cargo.toml b/tokio-stream/Cargo.toml index d3ea3076930..6f9dd7d532c 100644 --- a/tokio-stream/Cargo.toml +++ b/tokio-stream/Cargo.toml @@ -6,7 +6,7 @@ name = "tokio-stream" # - Create "tokio-stream-0.1.x" git tag. version = "0.1.15" edition = "2021" -rust-version = "1.63" +rust-version = "1.64" authors = ["Tokio Contributors "] license = "MIT" repository = "https://github.com/tokio-rs/tokio" diff --git a/tokio-test/Cargo.toml b/tokio-test/Cargo.toml index 076f79bf5e8..77aca7df022 100644 --- a/tokio-test/Cargo.toml +++ b/tokio-test/Cargo.toml @@ -6,7 +6,7 @@ name = "tokio-test" # - Create "tokio-test-0.4.x" git tag. version = "0.4.4" edition = "2021" -rust-version = "1.63" +rust-version = "1.64" authors = ["Tokio Contributors "] license = "MIT" repository = "https://github.com/tokio-rs/tokio" diff --git a/tokio-util/Cargo.toml b/tokio-util/Cargo.toml index a33e9c9cff7..124a172c469 100644 --- a/tokio-util/Cargo.toml +++ b/tokio-util/Cargo.toml @@ -6,7 +6,7 @@ name = "tokio-util" # - Create "tokio-util-0.7.x" git tag. version = "0.7.11" edition = "2021" -rust-version = "1.63" +rust-version = "1.64" authors = ["Tokio Contributors "] license = "MIT" repository = "https://github.com/tokio-rs/tokio" diff --git a/tokio/Cargo.toml b/tokio/Cargo.toml index ac759515315..02e3a437beb 100644 --- a/tokio/Cargo.toml +++ b/tokio/Cargo.toml @@ -8,7 +8,7 @@ name = "tokio" # - Create "v1.x.y" git tag. version = "1.38.0" edition = "2021" -rust-version = "1.63" +rust-version = "1.64" authors = ["Tokio Contributors "] license = "MIT" readme = "README.md" diff --git a/tokio/src/time/timeout.rs b/tokio/src/time/timeout.rs index 52ab9891c69..fa93a16910e 100644 --- a/tokio/src/time/timeout.rs +++ b/tokio/src/time/timeout.rs @@ -11,7 +11,7 @@ use crate::{ }; use pin_project_lite::pin_project; -use std::future::Future; +use std::future::{Future, IntoFuture}; use std::pin::Pin; use std::task::{self, Poll}; @@ -83,9 +83,9 @@ use std::task::{self, Poll}; /// [`Builder::enable_time`]: crate::runtime::Builder::enable_time /// [`Builder::enable_all`]: crate::runtime::Builder::enable_all #[track_caller] -pub fn timeout(duration: Duration, future: F) -> Timeout +pub fn timeout(duration: Duration, future: F) -> Timeout where - F: Future, + F: IntoFuture, { let location = trace::caller_location(); @@ -94,7 +94,7 @@ where Some(deadline) => Sleep::new_timeout(deadline, location), None => Sleep::far_future(location), }; - Timeout::new_with_delay(future, delay) + Timeout::new_with_delay(future.into_future(), delay) } /// Requires a `Future` to complete before the specified instant in time. @@ -142,14 +142,14 @@ where /// } /// # } /// ``` -pub fn timeout_at(deadline: Instant, future: F) -> Timeout +pub fn timeout_at(deadline: Instant, future: F) -> Timeout where - F: Future, + F: IntoFuture, { let delay = sleep_until(deadline); Timeout { - value: future, + value: future.into_future(), delay, } }