throw if napi function returns Err variant of Result<T>

This commit is contained in:
forehalo 2021-09-24 14:45:27 +08:00 committed by LongYinan
parent ee7a146ea1
commit f66f79e587
12 changed files with 53 additions and 37 deletions
crates/napi/src/bindgen_runtime

View file

@ -47,15 +47,10 @@ impl<const N: usize> CallbackInfo<N> {
}
pub fn get_arg(&self, index: usize) -> sys::napi_value {
*self
.args
.get(index)
.unwrap_or_else(|| panic!("index {} must < {}", index, N))
self.args[index]
}
pub fn this(&self) -> sys::napi_value {
debug_assert!(!self.this.is_null());
self.this
}