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+
16/// Resolves to the provided value.
27///
38/// This function is an async version of [`std::convert::identity`].
1520/// #
1621/// # })
1722/// ```
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+ }
2041}
You can’t perform that action at this time.
0 commit comments