@@ -3,7 +3,6 @@ use serde::{ser, Serialize};
3
3
use super :: LuaSerdeExt ;
4
4
use crate :: error:: { Error , Result } ;
5
5
use crate :: lua:: Lua ;
6
- use crate :: string:: String ;
7
6
use crate :: table:: Table ;
8
7
use crate :: value:: { IntoLua , Value } ;
9
8
@@ -287,7 +286,7 @@ impl<'lua> ser::Serializer for Serializer<'lua> {
287
286
_len : usize ,
288
287
) -> Result < Self :: SerializeTupleVariant > {
289
288
Ok ( SerializeTupleVariant {
290
- name : self . lua . create_string ( variant) ? ,
289
+ variant,
291
290
table : self . lua . create_table ( ) ?,
292
291
options : self . options ,
293
292
} )
@@ -331,7 +330,7 @@ impl<'lua> ser::Serializer for Serializer<'lua> {
331
330
len : usize ,
332
331
) -> Result < Self :: SerializeStructVariant > {
333
332
Ok ( SerializeStructVariant {
334
- name : self . lua . create_string ( variant) ? ,
333
+ variant,
335
334
table : self . lua . create_table_with_capacity ( 0 , len) ?,
336
335
options : self . options ,
337
336
} )
@@ -438,7 +437,7 @@ impl<'lua> ser::SerializeTupleStruct for SerializeSeq<'lua> {
438
437
439
438
#[ doc( hidden) ]
440
439
pub struct SerializeTupleVariant < ' lua > {
441
- name : String < ' lua > ,
440
+ variant : & ' static str ,
442
441
table : Table < ' lua > ,
443
442
options : Options ,
444
443
}
@@ -458,7 +457,7 @@ impl<'lua> ser::SerializeTupleVariant for SerializeTupleVariant<'lua> {
458
457
fn end ( self ) -> Result < Value < ' lua > > {
459
458
let lua = self . table . 0 . lua ;
460
459
let table = lua. create_table ( ) ?;
461
- table. raw_set ( self . name , self . table ) ?;
460
+ table. raw_set ( self . variant , self . table ) ?;
462
461
Ok ( Value :: Table ( table) )
463
462
}
464
463
}
@@ -553,7 +552,7 @@ impl<'lua> ser::SerializeStruct for SerializeStruct<'lua> {
553
552
554
553
#[ doc( hidden) ]
555
554
pub struct SerializeStructVariant < ' lua > {
556
- name : String < ' lua > ,
555
+ variant : & ' static str ,
557
556
table : Table < ' lua > ,
558
557
options : Options ,
559
558
}
@@ -575,7 +574,7 @@ impl<'lua> ser::SerializeStructVariant for SerializeStructVariant<'lua> {
575
574
fn end ( self ) -> Result < Value < ' lua > > {
576
575
let lua = self . table . 0 . lua ;
577
576
let table = lua. create_table_with_capacity ( 0 , 1 ) ?;
578
- table. raw_set ( self . name , self . table ) ?;
577
+ table. raw_set ( self . variant , self . table ) ?;
579
578
Ok ( Value :: Table ( table) )
580
579
}
581
580
}
0 commit comments