Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
John Hughes committed Jan 12, 2023
1 parent 4d381e0 commit b18b6fb
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions arrow2_convert_derive/src/derive_struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ impl<'a> From<&'a DeriveStruct> for Common<'a> {
.iter()
.enumerate()
.map(|(id, field)| {
field.syn.ident.as_ref().cloned().map_or_else(
|| syn::Member::Unnamed(id.into()),
|field| syn::Member::Named(field),
)
field
.syn
.ident
.as_ref()
.cloned()
.map_or_else(|| syn::Member::Unnamed(id.into()), syn::Member::Named)
})
.collect::<Vec<_>>();

Expand All @@ -47,10 +49,12 @@ impl<'a> From<&'a DeriveStruct> for Common<'a> {
.iter()
.enumerate()
.map(|(id, field)| {
field.syn.ident.as_ref().cloned().map_or_else(
|| syn::Member::Unnamed(id.into()),
|field| syn::Member::Named(field),
)
field
.syn
.ident
.as_ref()
.cloned()
.map_or_else(|| syn::Member::Unnamed(id.into()), syn::Member::Named)
})
.collect::<Vec<_>>();

Expand Down Expand Up @@ -107,11 +111,9 @@ pub fn expand_field(input: DeriveStruct) -> TokenStream {
<#ty as arrow2_convert::field::ArrowField>::data_type()
)
} else {
let field_names = field_members.iter().map(|field| {
match field {
syn::Member::Named(ident) => format_ident!("{}", ident),
syn::Member::Unnamed(index) => format_ident!("field_{}", index),
}
let field_names = field_members.iter().map(|field| match field {
syn::Member::Named(ident) => format_ident!("{}", ident),
syn::Member::Unnamed(index) => format_ident!("field_{}", index),
});
quote!(arrow2::datatypes::DataType::Struct(vec![
#(
Expand Down Expand Up @@ -519,4 +521,4 @@ pub fn expand_deserialize(input: DeriveStruct) -> TokenStream {
field_arrow_deserialize_impl,
])
}
}
}

0 comments on commit b18b6fb

Please sign in to comment.