@@ -11,42 +11,40 @@ use model::*;
11
11
pub fn build ( component : & AutoImpl , ref_ty : Trait ) -> Result < Tokens , String > {
12
12
let component_ident = & component. ident ;
13
13
14
- let impl_methods = try_iter ! (
15
- component. methods. iter( )
16
- . map( |method| {
17
- let valid_receiver = match method. arg_self {
18
- Some ( ref arg_self) => match * arg_self {
19
- SelfArg :: Ref ( _, syn:: Mutability :: Immutable ) => true ,
20
- _ => false
21
- } ,
22
- None => false
23
- } ;
24
-
25
- if !valid_receiver {
26
- Err ( format!( "auto impl for `{}` is only supported for methods with a `&self` reciever" , ref_ty) ) ?
27
- }
28
-
29
- method. build_impl_item( |method| {
30
- let fn_ident = & method. ident;
31
- let fn_args = & method. arg_pats;
32
-
33
- quote!( {
34
- self . as_ref( ) . #fn_ident( #( #fn_args) , * )
35
- } )
14
+ let impl_methods = component. methods . iter ( )
15
+ . map ( |method| {
16
+ let valid_receiver = match method. arg_self {
17
+ Some ( ref arg_self) => match * arg_self {
18
+ SelfArg :: Ref ( _, syn:: Mutability :: Immutable ) => true ,
19
+ _ => false
20
+ } ,
21
+ None => false
22
+ } ;
23
+
24
+ if !valid_receiver {
25
+ Err ( format ! ( "auto impl for `{}` is only supported for methods with a `&self` reciever" , ref_ty) ) ?
26
+ }
27
+
28
+ method. build_impl_item ( |method| {
29
+ let fn_ident = & method. ident ;
30
+ let fn_args = & method. arg_pats ;
31
+
32
+ quote ! ( {
33
+ self . as_ref( ) . #fn_ident( #( #fn_args) , * )
36
34
} )
37
35
} )
38
- ) ;
36
+ } )
37
+ . collect :: < Result < Vec < _ > , _ > > ( ) ?;
39
38
40
- let impl_associated_types = try_iter ! (
41
- component. associated_types. iter( )
42
- . map( |associated_type| {
43
- associated_type. build_impl_item( |associated_type| {
44
- let ty_ident = & associated_type. ident;
39
+ let impl_associated_types = component. associated_types . iter ( )
40
+ . map ( |associated_type| {
41
+ associated_type. build_impl_item ( |associated_type| {
42
+ let ty_ident = & associated_type. ident ;
45
43
46
- quote!( TAutoImpl :: #ty_ident)
47
- } )
44
+ quote ! ( TAutoImpl :: #ty_ident)
48
45
} )
49
- ) ;
46
+ } )
47
+ . collect :: < Result < Vec < _ > , _ > > ( ) ?;
50
48
51
49
let ( trait_tys, impl_lifetimes, impl_tys, where_clauses) = component. split_generics ( ) ;
52
50
0 commit comments