@@ -65,44 +65,67 @@ pub trait AsyncFnOnce<Args: Tuple> {
6565
6666mod impls {
6767 use super :: { AsyncFn , AsyncFnMut , AsyncFnOnce } ;
68- use crate :: future:: Future ;
6968 use crate :: marker:: Tuple ;
7069
7170 #[ 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
7372 where
74- < F as FnOnce < A > > :: Output : Future ,
73+ F : AsyncFn < A > ,
7574 {
76- type CallFuture < ' a > = < F as FnOnce < A > > :: Output where Self : ' a ;
75+ type CallFuture < ' a > = F :: CallFuture < ' a > where Self : ' a ;
7776
7877 extern "rust-call" fn async_call ( & self , args : A ) -> Self :: CallFuture < ' _ > {
79- self . call ( args)
78+ F :: async_call ( * self , args)
8079 }
8180 }
8281
8382 #[ 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
8584 where
86- < F as FnOnce < A > > :: Output : Future ,
85+ F : AsyncFn < A > ,
8786 {
88- type CallMutFuture < ' a > = < F as FnOnce < A > > :: Output where Self : ' a ;
87+ type CallMutFuture < ' a > = F :: CallFuture < ' a > where Self : ' a ;
8988
9089 extern "rust-call" fn async_call_mut ( & mut self , args : A ) -> Self :: CallMutFuture < ' _ > {
91- self . call_mut ( args)
90+ F :: async_call ( * self , args)
9291 }
9392 }
9493
9594 #[ 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
9796 where
98- < F as FnOnce < A > > :: Output : Future ,
97+ F : AsyncFn < A > ,
9998 {
100- type CallOnceFuture = <F as FnOnce < A > >:: Output ;
99+ type Output = F :: Output ;
100+ type CallOnceFuture = F :: CallFuture < ' a > ;
101101
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 > ;
103126
104127 extern "rust-call" fn async_call_once ( self , args : A ) -> Self :: CallOnceFuture {
105- self . call_once ( args)
128+ F :: async_call_mut ( self , args)
106129 }
107130 }
108131}
0 commit comments