Skip to content

Commit

Permalink
Fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
soareschen committed Jul 4, 2024
1 parent 76e82a1 commit b13e152
Showing 1 changed file with 20 additions and 23 deletions.
43 changes: 20 additions & 23 deletions crates/cgp-field-macro-lib/src/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,33 @@ pub fn derive_has_field_impls(item_struct: &ItemStruct) -> Vec<ItemImpl> {

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
Expand Down

0 comments on commit b13e152

Please sign in to comment.