@@ -500,11 +500,21 @@ impl FromLua for crate::Buffer {
500500impl IntoLua for StdString {
501501 #[ inline]
502502 fn into_lua ( self , lua : & Lua ) -> Result < Value > {
503+ #[ cfg( feature = "lua55" ) ]
504+ if true {
505+ return Ok ( Value :: String ( lua. create_external_string ( self ) ?) ) ;
506+ }
507+
503508 Ok ( Value :: String ( lua. create_string ( self ) ?) )
504509 }
505510
506511 #[ inline]
507512 unsafe fn push_into_stack ( self , lua : & RawLua ) -> Result < ( ) > {
513+ #[ cfg( feature = "lua55" ) ]
514+ if lua. unlikely_memory_error ( ) {
515+ return crate :: util:: push_external_string ( lua. state ( ) , self . into ( ) , false ) ;
516+ }
517+
508518 push_bytes_into_stack ( self , lua)
509519 }
510520}
@@ -591,6 +601,11 @@ impl FromLua for Box<str> {
591601impl IntoLua for CString {
592602 #[ inline]
593603 fn into_lua ( self , lua : & Lua ) -> Result < Value > {
604+ #[ cfg( feature = "lua55" ) ]
605+ if true {
606+ return Ok ( Value :: String ( lua. create_external_string ( self ) ?) ) ;
607+ }
608+
594609 Ok ( Value :: String ( lua. create_string ( self . as_bytes ( ) ) ?) )
595610 }
596611}
@@ -635,6 +650,11 @@ impl IntoLua for Cow<'_, CStr> {
635650impl IntoLua for BString {
636651 #[ inline]
637652 fn into_lua ( self , lua : & Lua ) -> Result < Value > {
653+ #[ cfg( feature = "lua55" ) ]
654+ if true {
655+ return Ok ( Value :: String ( lua. create_external_string ( self ) ?) ) ;
656+ }
657+
638658 Ok ( Value :: String ( lua. create_string ( self ) ?) )
639659 }
640660}
0 commit comments