@@ -65,13 +65,17 @@ pub(super) fn request_header_codec_inner(
65
65
& format ! ( "{}" , field_name) . to_ascii_uppercase ( ) ,
66
66
field_name. span ( ) ,
67
67
) ;
68
+ let type_name = if let Some ( value) = & has_option {
69
+ get_type_name ( value)
70
+ } else {
71
+ get_type_name ( & field. ty )
72
+ } ;
68
73
(
69
74
quote ! {
70
75
const #static_name: & ' static str = #camel_case_name;
71
76
} ,
72
77
(
73
- if let Some ( value) = has_option {
74
- let type_name = get_type_name ( value) ;
78
+ if has_option. is_some ( ) {
75
79
if type_name == "CheetahString" {
76
80
quote ! {
77
81
if let Some ( ref value) = self . #field_name {
@@ -92,17 +96,15 @@ pub(super) fn request_header_codec_inner(
92
96
}
93
97
} else {
94
98
quote ! {
95
- if let Some ( value) = self . #field_name {
99
+ if let Some ( ref value) = self . #field_name {
96
100
map. insert (
97
101
cheetah_string:: CheetahString :: from_static_str( Self :: #static_name) ,
98
102
cheetah_string:: CheetahString :: from_string( value. to_string( ) )
99
103
) ;
100
104
}
101
105
}
102
106
}
103
- } else {
104
- let type_name = get_type_name ( & field. ty ) ;
105
- if type_name == "CheetahString" {
107
+ } else if type_name == "CheetahString" {
106
108
quote ! {
107
109
map. insert (
108
110
cheetah_string:: CheetahString :: from_static_str( Self :: #static_name) ,
@@ -124,10 +126,9 @@ pub(super) fn request_header_codec_inner(
124
126
) ;
125
127
}
126
128
}
127
- } ,
129
+ ,
128
130
// build FromMap impl
129
131
if let Some ( value) = has_option {
130
- let type_name = get_type_name ( value) ;
131
132
if type_name == "CheetahString" || type_name == "String" {
132
133
if required {
133
134
quote ! {
@@ -161,7 +162,6 @@ pub(super) fn request_header_codec_inner(
161
162
}
162
163
} else {
163
164
let types = & field. ty ;
164
- let type_name = get_type_name ( types) ;
165
165
if type_name == "CheetahString" || type_name == "String" {
166
166
if required {
167
167
quote ! {
0 commit comments