From 0aa63ea9b865eed23cf69d7c063ad35c162b4d28 Mon Sep 17 00:00:00 2001 From: Gustavo Shigueo Date: Sun, 10 Nov 2024 18:35:01 -0300 Subject: [PATCH] Fix struct optional non-optional field --- macros/src/types/named.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/macros/src/types/named.rs b/macros/src/types/named.rs index 8035478e..3c1fa3d0 100644 --- a/macros/src/types/named.rs +++ b/macros/src/types/named.rs @@ -115,8 +115,17 @@ fn format_field( Optional { optional: false, .. }, - ) - | ( + ) => match extract_option_argument(&parsed_ty) { + Ok(inner_type) => { + if nullable { + (&parsed_ty, "?") + } else { + (inner_type, "?") + } + } + Err(_) => (&parsed_ty, ""), + }, + ( _, Optional { optional: true,