Skip to content

Commit

Permalink
fix: don't generate transformed types if there are no transform attrs
Browse files Browse the repository at this point in the history
  • Loading branch information
ten3roberts committed Mar 29, 2024
1 parent 60d3a9b commit db625c0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions flax-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ fn derive_fetch_struct(params: &Params) -> TokenStream {
// #(#field_names: <<#field_types as #crate_name::fetch::Fetch<'w>::Prepared> as #crate_name::fetch::PreparedFetch<#q_lf>>::Chunk,)*
// }

// #[automatically_derived]
#[automatically_derived]
impl #item_impl #crate_name::fetch::FetchItem<'q> for #fetch_name #fetch_ty {
type Item = #item_name #item_ty;
}
Expand Down Expand Up @@ -239,6 +239,10 @@ fn derive_transform(params: &Params) -> Result<TokenStream> {
..
} = params;

if attrs.transforms.is_empty() {
return Ok(quote! {});
}

// Replace all the fields with generics to allow transforming into different types
let ty_generics = ('A'..='Z')
.zip(fields)
Expand All @@ -265,8 +269,6 @@ fn derive_transform(params: &Params) -> Result<TokenStream> {
}
});

// eprintln!("types: {:?}", types);

quote! {
#vis struct #transformed_name<#(#ty_generics: for<'x> #crate_name::fetch::Fetch<'x>),*>{
#(#fields)*
Expand Down

0 comments on commit db625c0

Please sign in to comment.