low-luajit 0.1.0

Low level but safe bindings to the LuaJIT C API with no dependencies and no-std support to create Lua modules using Rust.
Documentation
use crate::{LuaState, ffi};

/// Boolean related functions.
impl LuaState {
	/// Returns `true` if the value at the given acceptable `index` is a boolean, `false` otherwise.
	#[inline]
	#[must_use]
	pub fn is_boolean(&self, index: i32) -> bool {
		// SAFETY: self.0 is always valid.
		unsafe { ffi::lua_isboolean(self.0, index) != 0 }
	}

	/// Converts the value at the given acceptable `index` to a boolean and returns it.
	///
	/// Any value besides `false` or `nil` is converted to `true`, `false` otherwise.
	///
	/// This conversion *does not* affect the element in the stack itself (it stays as is).
	#[inline]
	#[must_use]
	pub fn to_boolean(&self, index: i32) -> bool {
		// SAFETY: self.0 is always valid.
		unsafe { ffi::lua_toboolean(self.0, index) != 0 }
	}

	/// Pushes the given `boolean` onto the stack.
	#[inline]
	pub fn push_boolean(&mut self, boolean: bool) {
		// SAFETY: self.0 is always valid.
		unsafe { ffi::lua_pushboolean(self.0, i32::from(boolean)); }
	}
}