File tree 1 file changed +12
-6
lines changed
1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -169,12 +169,15 @@ fn impl_struct(input: Struct) -> TokenStream {
169
169
let from = unoptional_type ( from_field. ty ) ;
170
170
let source_var = Ident :: new ( "source" , span) ;
171
171
let body = from_initializer ( from_field, backtrace_field, & source_var) ;
172
+ let from_function = quote ! {
173
+ fn from( #source_var: #from) -> Self {
174
+ #ty #body
175
+ }
176
+ } ;
172
177
let from_impl = quote_spanned ! { span=>
173
178
#[ automatically_derived]
174
179
impl #impl_generics :: core:: convert:: From <#from> for #ty #ty_generics #where_clause {
175
- fn from( #source_var: #from) -> Self {
176
- #ty #body
177
- }
180
+ #from_function
178
181
}
179
182
} ;
180
183
Some ( quote ! {
@@ -436,12 +439,15 @@ fn impl_enum(input: Enum) -> TokenStream {
436
439
let from = unoptional_type ( from_field. ty ) ;
437
440
let source_var = Ident :: new ( "source" , span) ;
438
441
let body = from_initializer ( from_field, backtrace_field, & source_var) ;
442
+ let from_function = quote ! {
443
+ fn from( #source_var: #from) -> Self {
444
+ #ty:: #variant #body
445
+ }
446
+ } ;
439
447
let from_impl = quote_spanned ! { span=>
440
448
#[ automatically_derived]
441
449
impl #impl_generics :: core:: convert:: From <#from> for #ty #ty_generics #where_clause {
442
- fn from( #source_var: #from) -> Self {
443
- #ty:: #variant #body
444
- }
450
+ #from_function
445
451
}
446
452
} ;
447
453
Some ( quote ! {
You can’t perform that action at this time.
0 commit comments