From 84fe5f7f761e5a9669ae00df3f6e48ef2814272c Mon Sep 17 00:00:00 2001 From: Alex Orlenko Date: Wed, 7 Jul 2021 12:54:19 +0100 Subject: Make `protect_lua` as a smart macro to choose from C/closure --- src/serde/ser.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/serde/ser.rs') diff --git a/src/serde/ser.rs b/src/serde/ser.rs index 4c6423c..aa06a58 100644 --- a/src/serde/ser.rs +++ b/src/serde/ser.rs @@ -9,7 +9,7 @@ use crate::lua::Lua; use crate::string::String; use crate::table::Table; use crate::types::Integer; -use crate::util::{check_stack, protect_lua, StackGuard}; +use crate::util::{check_stack, StackGuard}; use crate::value::{ToLua, Value}; /// A struct for serializing Rust values into Lua values. @@ -322,8 +322,8 @@ impl<'lua> ser::SerializeSeq for SerializeVec<'lua> { lua.push_ref(&self.table.0); lua.push_value(value)?; - let len = ffi::lua_rawlen(lua.state, -2) as Integer; - protect_lua(lua.state, 2, 0, |state| { + protect_lua!(lua.state, 2, 0, state => { + let len = ffi::lua_rawlen(state, -2) as Integer; ffi::lua_rawseti(state, -2, len + 1); }) } -- cgit v1.2.3