diff options
author | Alex Orlenko <zxteam@protonmail.com> | 2021-07-07 12:54:19 +0100 |
---|---|---|
committer | Alex Orlenko <zxteam@protonmail.com> | 2021-07-07 12:54:19 +0100 |
commit | 84fe5f7f761e5a9669ae00df3f6e48ef2814272c (patch) | |
tree | f3789618d0e9b6f7437e29ba01e7525ef0d2d217 /src/serde/ser.rs | |
parent | 1fe583027bce76a4b980242a61ad641e6df30a16 (diff) | |
download | mlua-84fe5f7f761e5a9669ae00df3f6e48ef2814272c.zip |
Make `protect_lua` as a smart macro to choose from C/closure
Diffstat (limited to 'src/serde/ser.rs')
-rw-r--r-- | src/serde/ser.rs | 6 |
1 files changed, 3 insertions, 3 deletions
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); }) } |