From af6e8d5e6e78bc6ae2d84811409b4284cecf21b7 Mon Sep 17 00:00:00 2001 From: naskya Date: Fri, 12 Jul 2024 01:42:16 +0900 Subject: [PATCH] fix: use underlying_ty for default nested type name --- optionalize-derive/src/util.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/optionalize-derive/src/util.rs b/optionalize-derive/src/util.rs index c9c2d8b..f37cd2c 100644 --- a/optionalize-derive/src/util.rs +++ b/optionalize-derive/src/util.rs @@ -28,7 +28,7 @@ pub(crate) fn struct_fields_info<'a>( .map(|field| { let inner_ty = get_generic_ty("Option", &field.ty); let attr = helper_attr(&field.attrs, helper); - let ty = &field.ty; + let underlying_ty = inner_ty.unwrap_or(&field.ty); FieldInfo { 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)"); } 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(), - underlying_ty: inner_ty.unwrap_or(&field.ty), + underlying_ty, } }) .collect()