@@ -180,8 +180,11 @@ impl<'a> Signature<'a> {
180180 if self . is_async {
181181 proxy_real. extend ( quote ! { . await } )
182182 }
183- if let Some ( wrapped_self) = self . wrap_self ( morphed_ty, real_self, & proxy_real) ? {
184- proxy_real = wrapped_self;
183+
184+ if let Some ( output) = self . output {
185+ if let Some ( wrapped_self) = Self :: wrap_self ( output, morphed_ty, real_self, & proxy_real) ? {
186+ proxy_real = wrapped_self;
187+ }
185188 }
186189
187190 let ret = match & self . method_data {
@@ -255,26 +258,24 @@ impl<'a> Signature<'a> {
255258 }
256259
257260 fn wrap_self (
258- & self ,
261+ ty : & Type ,
259262 morphed_ty : & syn:: TypePath ,
260263 real_self : SelfType ,
261264 block : & TokenStream ,
262265 ) -> darling:: Result < Option < TokenStream > > {
263- // TODO: use let-else once we bump MSRV to 1.65.0
264- let output = match self . output {
265- Some ( output) => output,
266- None => return Ok ( None ) ,
267- } ;
268- if !contains_self ( output, morphed_ty) {
266+ if !contains_self ( ty, morphed_ty) {
269267 return Ok ( None ) ;
270268 }
271269
272270 let is_self = |ty : & syn:: TypePath | {
273271 ty == morphed_ty || ( ty. qself . is_none ( ) && ty. path . is_ident ( "Self" ) )
274272 } ;
275273
276- let output = match output {
274+ let output = match ty {
277275 syn:: Type :: Path ( output) => output,
276+ syn:: Type :: Tuple ( tuple) => {
277+ return Self :: wrap_self_tuple ( block, tuple, morphed_ty, real_self) ;
278+ } ,
278279 output => return Err ( unhandled_self_return ( output) ) ,
279280 } ;
280281
@@ -341,6 +342,32 @@ impl<'a> Signature<'a> {
341342
342343 Ok ( Some ( wrapped) )
343344 }
345+
346+ fn wrap_self_tuple (
347+ block : & TokenStream ,
348+ tuple : & syn:: TypeTuple ,
349+ morphed_ty : & syn:: TypePath ,
350+ real_self : SelfType ) -> darling:: Result < Option < TokenStream > > {
351+ let elements = tuple. elems
352+ . iter ( )
353+ . enumerate ( )
354+ . map ( |e| {
355+ let index = syn:: Index :: from ( e. 0 ) ;
356+ let ty = e. 1 ;
357+
358+ let tuple_index = quote ! { tuple. #index } ;
359+ let wrapped = Self :: wrap_self ( ty, morphed_ty, real_self, & tuple_index) ?;
360+
361+ Ok ( wrapped. unwrap_or ( tuple_index) )
362+ } )
363+ . collect :: < darling:: Result < Vec < TokenStream > > > ( ) ?;
364+
365+ Ok ( Some ( quote ! { {
366+ let tuple = #block;
367+
368+ ( # ( #elements) , * )
369+ } } ) )
370+ }
344371}
345372
346373impl MethodData < ' _ > {
0 commit comments