File tree Expand file tree Collapse file tree 1 file changed +23
-2
lines changed Expand file tree Collapse file tree 1 file changed +23
-2
lines changed Original file line number Diff line number Diff line change
1
+ use core:: future:: Future ;
2
+ use core:: pin:: Pin ;
3
+
4
+ use crate :: task:: { Context , Poll } ;
5
+
1
6
/// Resolves to the provided value.
2
7
///
3
8
/// This function is an async version of [`std::convert::identity`].
15
20
/// #
16
21
/// # })
17
22
/// ```
18
- pub async fn ready < T > ( val : T ) -> T {
19
- val
23
+ pub fn ready < T > ( val : T ) -> Ready < T > {
24
+ Ready ( Some ( val) )
25
+ }
26
+
27
+ /// This future is constructed by the [`ready`] function.
28
+ ///
29
+ /// [`ready`]: fn.ready.html
30
+ #[ derive( Debug ) ]
31
+ pub struct Ready < T > ( Option < T > ) ;
32
+
33
+ impl < T > Unpin for Ready < T > { }
34
+
35
+ impl < T > Future for Ready < T > {
36
+ type Output = T ;
37
+
38
+ fn poll ( mut self : Pin < & mut Self > , _: & mut Context < ' _ > ) -> Poll < T > {
39
+ Poll :: Ready ( self . 0 . take ( ) . unwrap ( ) )
40
+ }
20
41
}
You can’t perform that action at this time.
0 commit comments