From f05ced0782fb466016dbf7bb77d1599b2658f879 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Wed, 13 Apr 2022 23:50:33 +0800 Subject: [PATCH] feat(napi): add from_unknown method on FromNapiValue --- crates/napi/src/bindgen_runtime/js_values.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/napi/src/bindgen_runtime/js_values.rs b/crates/napi/src/bindgen_runtime/js_values.rs index bae2cff2..54ebcd88 100644 --- a/crates/napi/src/bindgen_runtime/js_values.rs +++ b/crates/napi/src/bindgen_runtime/js_values.rs @@ -89,6 +89,10 @@ pub trait FromNapiValue: Sized { /// /// this function called to convert napi values to native rust values unsafe fn from_napi_value(env: sys::napi_env, napi_val: sys::napi_value) -> Result; + + fn from_unknown(value: JsUnknown) -> Result { + unsafe { Self::from_napi_value(value.0.env, value.0.value) } + } } pub trait FromNapiRef {