Skip to content

Commit 5129214

Browse files
committed
Add fastpath push_into_stack/from_stack methods for bool type
1 parent dfd82ed commit 5129214

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/conversion.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,12 @@ impl<'lua> IntoLua<'lua> for bool {
434434
fn into_lua(self, _: &'lua Lua) -> Result<Value<'lua>> {
435435
Ok(Value::Boolean(self))
436436
}
437+
438+
#[inline]
439+
unsafe fn push_into_stack(self, lua: &'lua Lua) -> Result<()> {
440+
ffi::lua_pushboolean(lua.state(), self as c_int);
441+
Ok(())
442+
}
437443
}
438444

439445
impl<'lua> FromLua<'lua> for bool {
@@ -445,6 +451,10 @@ impl<'lua> FromLua<'lua> for bool {
445451
_ => Ok(true),
446452
}
447453
}
454+
455+
unsafe fn from_stack(idx: c_int, lua: &'lua Lua) -> Result<Self> {
456+
Ok(ffi::lua_toboolean(lua.state(), idx) != 0)
457+
}
448458
}
449459

450460
impl<'lua> IntoLua<'lua> for LightUserData {

0 commit comments

Comments
 (0)