diff --git a/crates/cgp-field-macro-lib/src/field.rs b/crates/cgp-field-macro-lib/src/field.rs index bb9b3e0..eac91b2 100644 --- a/crates/cgp-field-macro-lib/src/field.rs +++ b/crates/cgp-field-macro-lib/src/field.rs @@ -11,36 +11,33 @@ pub fn derive_has_field_impls(item_struct: &ItemStruct) -> Vec { let mut item_impls = Vec::new(); - match &item_struct.fields { - Fields::Named(fields) => { - for field in fields.named.iter() { - let field_ident = field.ident.as_ref().unwrap(); + if let Fields::Named(fields) = &item_struct.fields { + for field in fields.named.iter() { + let field_ident = field.ident.as_ref().unwrap(); - let field_symbol = symbol_from_string(&field_ident.to_string()); + let field_symbol = symbol_from_string(&field_ident.to_string()); - let field_type = &field.ty; + let field_type = &field.ty; - let item_impl: ItemImpl = parse_quote! { - impl #impl_generics HasField< #field_symbol > - for #struct_ident #ty_generics - #where_clause + let item_impl: ItemImpl = parse_quote! { + impl #impl_generics HasField< #field_symbol > + for #struct_ident #ty_generics + #where_clause + { + type Field = #field_type; + + fn get_field( + &self, + key: ::core::marker::PhantomData< #field_symbol >, + ) -> &Self::Field { - type Field = #field_type; - - fn get_field( - &self, - key: ::core::marker::PhantomData< #field_symbol >, - ) -> &Self::Field - { - &self. #field_ident - } + &self. #field_ident } - }; + } + }; - item_impls.push(item_impl); - } + item_impls.push(item_impl); } - _ => {} } item_impls