fix: use underlying_ty for default nested type name

This commit is contained in:
naskya 2024-07-12 01:42:16 +09:00
parent 76358fc961
commit af6e8d5e6e
Signed by: naskya
GPG key ID: 712D413B3A9FED5C

View file

@ -28,7 +28,7 @@ pub(crate) fn struct_fields_info<'a>(
.map(|field| { .map(|field| {
let inner_ty = get_generic_ty("Option", &field.ty); let inner_ty = get_generic_ty("Option", &field.ty);
let attr = helper_attr(&field.attrs, helper); let attr = helper_attr(&field.attrs, helper);
let ty = &field.ty; let underlying_ty = inner_ty.unwrap_or(&field.ty);
FieldInfo { FieldInfo {
ident: field.ident.as_ref(), ident: field.ident.as_ref(),
@ -41,10 +41,10 @@ pub(crate) fn struct_fields_info<'a>(
panic!("usage of `opt` attribute is incorrect (unknown key is present)"); panic!("usage of `opt` attribute is incorrect (unknown key is present)");
} }
path path
}).unwrap_or(syn::Ident::new(&format!("{}Opt", quote::quote!(#ty)), field.span()).into()) }).unwrap_or(syn::Ident::new(&format!("{}Opt", quote::quote!(#underlying_ty)), field.span()).into())
}), }),
is_option: inner_ty.is_some(), is_option: inner_ty.is_some(),
underlying_ty: inner_ty.unwrap_or(&field.ty), underlying_ty,
} }
}) })
.collect() .collect()