Skip to content

Commit

Permalink
Change unit type field name
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrobbel committed Mar 27, 2024
1 parent 7fbcdb2 commit c9dc1a2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions narrow-derive/src/struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,12 @@ impl Struct<'_> {
.extend(self.where_predicate_fields(parse_quote!(#narrow::arrow::Array)));
let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();
let ident = self.array_struct_ident();

let field_name = self.ident.to_string();
let tokens = if matches!(self.fields, Fields::Unit) {
quote!(impl #impl_generics #narrow::arrow::StructArrayTypeFields for #ident #ty_generics #where_clause {
fn fields() -> ::arrow_schema::Fields {
::arrow_schema::Fields::from([
::std::sync::Arc::new(::arrow_schema::Field::new("_0", ::arrow_schema::DataType::Null, false)),
::std::sync::Arc::new(::arrow_schema::Field::new(#field_name, ::arrow_schema::DataType::Null, false)),
])
}
})
Expand Down
3 changes: 3 additions & 0 deletions src/array/struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,9 @@ mod tests {
#[cfg(feature = "derive")]
#[test]
fn derive() {
#[derive(crate::ArrayType)]
struct Unit;

#[derive(crate::ArrayType)]
struct Foo(Option<Bar<u32>>);

Expand Down

0 comments on commit c9dc1a2

Please sign in to comment.