Add is_none and is_none_or_nil

This commit is contained in:
William Venner 2022-07-16 21:12:39 +01:00
parent 9b3c37369b
commit f0e1f92782
3 changed files with 13 additions and 2 deletions

2
Cargo.lock generated
View File

@ -109,7 +109,7 @@ dependencies = [
[[package]]
name = "gmod"
version = "16.0.1"
version = "16.0.2"
dependencies = [
"cfg_table",
"cstr",

View File

@ -1,6 +1,6 @@
[package]
name = "gmod"
version = "16.0.1"
version = "16.0.2"
authors = ["William Venner <william@venner.io>"]
edition = "2021"
license = "MIT"

View File

@ -132,10 +132,21 @@ impl LuaState {
}
#[inline(always)]
/// You may be looking for `is_none_or_nil`
pub unsafe fn is_nil(&self, index: i32) -> bool {
(LUA_SHARED.lua_type)(*self, index) == LUA_TNIL
}
#[inline(always)]
pub unsafe fn is_none(&self, index: i32) -> bool {
(LUA_SHARED.lua_type)(*self, index) == LUA_TNONE
}
#[inline(always)]
pub unsafe fn is_none_or_nil(&self, index: i32) -> bool {
self.is_nil(index) || self.is_none(index)
}
#[inline(always)]
pub unsafe fn is_function(&self, index: i32) -> bool {
(LUA_SHARED.lua_type)(*self, index) == LUA_TFUNCTION