@@ -3,7 +3,6 @@ use serde::{ser, Serialize};
33use super :: LuaSerdeExt ;
44use crate :: error:: { Error , Result } ;
55use crate :: lua:: Lua ;
6- use crate :: string:: String ;
76use crate :: table:: Table ;
87use crate :: value:: { IntoLua , Value } ;
98
@@ -287,7 +286,7 @@ impl<'lua> ser::Serializer for Serializer<'lua> {
287286 _len : usize ,
288287 ) -> Result < Self :: SerializeTupleVariant > {
289288 Ok ( SerializeTupleVariant {
290- name : self . lua . create_string ( variant) ? ,
289+ variant,
291290 table : self . lua . create_table ( ) ?,
292291 options : self . options ,
293292 } )
@@ -331,7 +330,7 @@ impl<'lua> ser::Serializer for Serializer<'lua> {
331330 len : usize ,
332331 ) -> Result < Self :: SerializeStructVariant > {
333332 Ok ( SerializeStructVariant {
334- name : self . lua . create_string ( variant) ? ,
333+ variant,
335334 table : self . lua . create_table_with_capacity ( 0 , len) ?,
336335 options : self . options ,
337336 } )
@@ -438,7 +437,7 @@ impl<'lua> ser::SerializeTupleStruct for SerializeSeq<'lua> {
438437
439438#[ doc( hidden) ]
440439pub struct SerializeTupleVariant < ' lua > {
441- name : String < ' lua > ,
440+ variant : & ' static str ,
442441 table : Table < ' lua > ,
443442 options : Options ,
444443}
@@ -458,7 +457,7 @@ impl<'lua> ser::SerializeTupleVariant for SerializeTupleVariant<'lua> {
458457 fn end ( self ) -> Result < Value < ' lua > > {
459458 let lua = self . table . 0 . lua ;
460459 let table = lua. create_table ( ) ?;
461- table. raw_set ( self . name , self . table ) ?;
460+ table. raw_set ( self . variant , self . table ) ?;
462461 Ok ( Value :: Table ( table) )
463462 }
464463}
@@ -553,7 +552,7 @@ impl<'lua> ser::SerializeStruct for SerializeStruct<'lua> {
553552
554553#[ doc( hidden) ]
555554pub struct SerializeStructVariant < ' lua > {
556- name : String < ' lua > ,
555+ variant : & ' static str ,
557556 table : Table < ' lua > ,
558557 options : Options ,
559558}
@@ -575,7 +574,7 @@ impl<'lua> ser::SerializeStructVariant for SerializeStructVariant<'lua> {
575574 fn end ( self ) -> Result < Value < ' lua > > {
576575 let lua = self . table . 0 . lua ;
577576 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 ) ?;
579578 Ok ( Value :: Table ( table) )
580579 }
581580}
0 commit comments