Add fastpath push_into_stack/from_stack methods for bool type

This commit is contained in:
Alex Orlenko
2024-01-26 14:07:56 +00:00
parent dfd82edc42
commit 512921404c
+10
View File
@@ -434,6 +434,12 @@ impl<'lua> IntoLua<'lua> for bool {
fn into_lua(self, _: &'lua Lua) -> Result<Value<'lua>> {
Ok(Value::Boolean(self))
}
#[inline]
unsafe fn push_into_stack(self, lua: &'lua Lua) -> Result<()> {
ffi::lua_pushboolean(lua.state(), self as c_int);
Ok(())
}
}
impl<'lua> FromLua<'lua> for bool {
@@ -445,6 +451,10 @@ impl<'lua> FromLua<'lua> for bool {
_ => Ok(true),
}
}
unsafe fn from_stack(idx: c_int, lua: &'lua Lua) -> Result<Self> {
Ok(ffi::lua_toboolean(lua.state(), idx) != 0)
}
}
impl<'lua> IntoLua<'lua> for LightUserData {