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]]
name = "gmod"
version = "16.0.0"
version = "16.0.1"
dependencies = [
"cfg_table",
"cstr",

View File

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

View File

@ -62,3 +62,12 @@ impl<E: DisplayLuaError> From<Result<i32, E>> for ValuesReturned {
}
}
}
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()) }
}
}
}