Allow returning Result<(), E> where E: DisplayLuaError

This commit is contained in:
William Venner 2022-07-16 19:26:00 +01:00
parent 85c1d6a82a
commit 9b3c37369b
3 changed files with 11 additions and 2 deletions

2
Cargo.lock generated
View File

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

View File

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

View File

@ -61,4 +61,13 @@ impl<E: DisplayLuaError> From<Result<i32, E>> for ValuesReturned {
Err(err) => unsafe { super::state().error(err.display_lua_error().as_ref()) } Err(err) => unsafe { super::state().error(err.display_lua_error().as_ref()) }
} }
} }
}
impl<E: DisplayLuaError> From<Result<(), E>> for ValuesReturned {
#[inline(always)]
fn from(res: Result<(), E>) -> ValuesReturned {
match res {
Ok(_) => ValuesReturned(0),
Err(err) => unsafe { super::state().error(err.display_lua_error().as_ref()) }
}
}
} }