@@ -11,7 +11,7 @@ use crate::{
11
11
} ;
12
12
13
13
use pin_project_lite:: pin_project;
14
- use std:: future:: Future ;
14
+ use std:: future:: { Future , IntoFuture } ;
15
15
use std:: pin:: Pin ;
16
16
use std:: task:: { self , Poll } ;
17
17
@@ -83,9 +83,9 @@ use std::task::{self, Poll};
83
83
/// [`Builder::enable_time`]: crate::runtime::Builder::enable_time
84
84
/// [`Builder::enable_all`]: crate::runtime::Builder::enable_all
85
85
#[ track_caller]
86
- pub fn timeout < F > ( duration : Duration , future : F ) -> Timeout < F >
86
+ pub fn timeout < F > ( duration : Duration , future : F ) -> Timeout < F :: IntoFuture >
87
87
where
88
- F : Future ,
88
+ F : IntoFuture ,
89
89
{
90
90
let location = trace:: caller_location ( ) ;
91
91
94
94
Some ( deadline) => Sleep :: new_timeout ( deadline, location) ,
95
95
None => Sleep :: far_future ( location) ,
96
96
} ;
97
- Timeout :: new_with_delay ( future, delay)
97
+ Timeout :: new_with_delay ( future. into_future ( ) , delay)
98
98
}
99
99
100
100
/// Requires a `Future` to complete before the specified instant in time.
@@ -142,14 +142,14 @@ where
142
142
/// }
143
143
/// # }
144
144
/// ```
145
- pub fn timeout_at < F > ( deadline : Instant , future : F ) -> Timeout < F >
145
+ pub fn timeout_at < F > ( deadline : Instant , future : F ) -> Timeout < F :: IntoFuture >
146
146
where
147
- F : Future ,
147
+ F : IntoFuture ,
148
148
{
149
149
let delay = sleep_until ( deadline) ;
150
150
151
151
Timeout {
152
- value : future,
152
+ value : future. into_future ( ) ,
153
153
delay,
154
154
}
155
155
}
0 commit comments