@@ -65,44 +65,67 @@ pub trait AsyncFnOnce<Args: Tuple> {
65
65
66
66
mod impls {
67
67
use super :: { AsyncFn , AsyncFnMut , AsyncFnOnce } ;
68
- use crate :: future:: Future ;
69
68
use crate :: marker:: Tuple ;
70
69
71
70
#[ unstable( feature = "async_fn_traits" , issue = "none" ) ]
72
- impl < F : Fn < A > , A : Tuple > AsyncFn < A > for F
71
+ impl < A : Tuple , F : ? Sized > AsyncFn < A > for & F
73
72
where
74
- < F as FnOnce < A > > :: Output : Future ,
73
+ F : AsyncFn < A > ,
75
74
{
76
- type CallFuture < ' a > = < F as FnOnce < A > > :: Output where Self : ' a ;
75
+ type CallFuture < ' a > = F :: CallFuture < ' a > where Self : ' a ;
77
76
78
77
extern "rust-call" fn async_call ( & self , args : A ) -> Self :: CallFuture < ' _ > {
79
- self . call ( args)
78
+ F :: async_call ( * self , args)
80
79
}
81
80
}
82
81
83
82
#[ unstable( feature = "async_fn_traits" , issue = "none" ) ]
84
- impl < F : FnMut < A > , A : Tuple > AsyncFnMut < A > for F
83
+ impl < A : Tuple , F : ? Sized > AsyncFnMut < A > for & F
85
84
where
86
- < F as FnOnce < A > > :: Output : Future ,
85
+ F : AsyncFn < A > ,
87
86
{
88
- type CallMutFuture < ' a > = < F as FnOnce < A > > :: Output where Self : ' a ;
87
+ type CallMutFuture < ' a > = F :: CallFuture < ' a > where Self : ' a ;
89
88
90
89
extern "rust-call" fn async_call_mut ( & mut self , args : A ) -> Self :: CallMutFuture < ' _ > {
91
- self . call_mut ( args)
90
+ F :: async_call ( * self , args)
92
91
}
93
92
}
94
93
95
94
#[ unstable( feature = "async_fn_traits" , issue = "none" ) ]
96
- impl < F : FnOnce < A > , A : Tuple > AsyncFnOnce < A > for F
95
+ impl < ' a , A : Tuple , F : ? Sized > AsyncFnOnce < A > for & ' a F
97
96
where
98
- < F as FnOnce < A > > :: Output : Future ,
97
+ F : AsyncFn < A > ,
99
98
{
100
- type CallOnceFuture = <F as FnOnce < A > >:: Output ;
99
+ type Output = F :: Output ;
100
+ type CallOnceFuture = F :: CallFuture < ' a > ;
101
101
102
- type Output = <<F as FnOnce < A > >:: Output as Future >:: Output ;
102
+ extern "rust-call" fn async_call_once ( self , args : A ) -> Self :: CallOnceFuture {
103
+ F :: async_call ( self , args)
104
+ }
105
+ }
106
+
107
+ #[ unstable( feature = "async_fn_traits" , issue = "none" ) ]
108
+ impl < A : Tuple , F : ?Sized > AsyncFnMut < A > for & mut F
109
+ where
110
+ F : AsyncFnMut < A > ,
111
+ {
112
+ type CallMutFuture < ' a > = F :: CallMutFuture < ' a > where Self : ' a ;
113
+
114
+ extern "rust-call" fn async_call_mut ( & mut self , args : A ) -> Self :: CallMutFuture < ' _ > {
115
+ F :: async_call_mut ( * self , args)
116
+ }
117
+ }
118
+
119
+ #[ unstable( feature = "async_fn_traits" , issue = "none" ) ]
120
+ impl < ' a , A : Tuple , F : ?Sized > AsyncFnOnce < A > for & ' a mut F
121
+ where
122
+ F : AsyncFnMut < A > ,
123
+ {
124
+ type Output = F :: Output ;
125
+ type CallOnceFuture = F :: CallMutFuture < ' a > ;
103
126
104
127
extern "rust-call" fn async_call_once ( self , args : A ) -> Self :: CallOnceFuture {
105
- self . call_once ( args)
128
+ F :: async_call_mut ( self , args)
106
129
}
107
130
}
108
131
}
0 commit comments