File tree Expand file tree Collapse file tree 3 files changed +16
-6
lines changed Expand file tree Collapse file tree 3 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -73,7 +73,7 @@ impl Serialize for Date {
73
73
{
74
74
let mut buf = DateTimeBuffer :: new ( ) ;
75
75
self . write_buf ( & mut buf) ;
76
- serializer. serialize_str ( str_from_slice ! ( buf. as_ptr( ) , buf. len( ) ) )
76
+ serializer. serialize_unit_struct ( str_from_slice ! ( buf. as_ptr( ) , buf. len( ) ) )
77
77
}
78
78
}
79
79
@@ -124,7 +124,7 @@ impl Serialize for Time {
124
124
if self . write_buf ( & mut buf) . is_err ( ) {
125
125
err ! ( SerializeError :: DatetimeLibraryUnsupported )
126
126
} ;
127
- serializer. serialize_str ( str_from_slice ! ( buf. as_ptr( ) , buf. len( ) ) )
127
+ serializer. serialize_unit_struct ( str_from_slice ! ( buf. as_ptr( ) , buf. len( ) ) )
128
128
}
129
129
}
130
130
@@ -243,6 +243,6 @@ impl Serialize for DateTime {
243
243
if self . write_buf ( & mut buf, self . opts ) . is_err ( ) {
244
244
err ! ( SerializeError :: DatetimeLibraryUnsupported )
245
245
}
246
- serializer. serialize_str ( str_from_slice ! ( buf. as_ptr( ) , buf. len( ) ) )
246
+ serializer. serialize_unit_struct ( str_from_slice ! ( buf. as_ptr( ) , buf. len( ) ) )
247
247
}
248
248
}
Original file line number Diff line number Diff line change @@ -60,6 +60,6 @@ impl Serialize for UUID {
60
60
{
61
61
let mut buf = arrayvec:: ArrayVec :: < u8 , 36 > :: new ( ) ;
62
62
self . write_buf ( & mut buf) ;
63
- serializer. serialize_str ( str_from_slice ! ( buf. as_ptr( ) , buf. len( ) ) )
63
+ serializer. serialize_unit_struct ( str_from_slice ! ( buf. as_ptr( ) , buf. len( ) ) )
64
64
}
65
65
}
Original file line number Diff line number Diff line change @@ -166,8 +166,18 @@ where
166
166
. map_err ( Error :: io)
167
167
}
168
168
169
- fn serialize_unit_struct ( self , _name : & ' static str ) -> Result < ( ) > {
170
- unreachable ! ( ) ;
169
+ #[ inline( always) ]
170
+ fn serialize_unit_struct ( self , name : & ' static str ) -> Result < ( ) > {
171
+ debug_assert ! ( name. len( ) <= 36 ) ;
172
+ reserve_minimum ! ( self . writer) ;
173
+ unsafe {
174
+ self . writer . write_reserved_punctuation ( b'"' ) . unwrap ( ) ;
175
+ self . writer
176
+ . write_reserved_fragment ( name. as_bytes ( ) )
177
+ . unwrap ( ) ;
178
+ self . writer . write_reserved_punctuation ( b'"' ) . unwrap ( ) ;
179
+ }
180
+ Ok ( ( ) )
171
181
}
172
182
173
183
fn serialize_unit_variant (
You can’t perform that action at this time.
0 commit comments