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()