summaryrefslogtreecommitdiff
path: root/ext/napi/value.rs
diff options
context:
space:
mode:
authorsnek <the@snek.dev>2024-06-10 09:20:44 -0700
committerGitHub <noreply@github.com>2024-06-10 16:20:44 +0000
commite3b2ee183bc7497ec0432bc764678f5eda6495a7 (patch)
tree7a5fa0208ef56cb83fa6bae9bad0bc89334ed533 /ext/napi/value.rs
parent7c5dbd5d54770dba5e56442b633e9597403ef5da (diff)
fix: Rewrite Node-API (#24101)
Phase 1 node-api rewrite
Diffstat (limited to 'ext/napi/value.rs')
-rw-r--r--ext/napi/value.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/ext/napi/value.rs b/ext/napi/value.rs
index c1607f2c2..6fb96758c 100644
--- a/ext/napi/value.rs
+++ b/ext/napi/value.rs
@@ -37,6 +37,19 @@ where
}
}
+impl<'s, T> From<Option<v8::Local<'s, T>>> for napi_value<'s>
+where
+ v8::Local<'s, T>: Into<v8::Local<'s, v8::Value>>,
+{
+ fn from(v: Option<v8::Local<'s, T>>) -> Self {
+ if let Some(v) = v {
+ NapiValue::from(v)
+ } else {
+ Self(None, std::marker::PhantomData)
+ }
+ }
+}
+
const _: () = {
assert!(
std::mem::size_of::<napi_value>() == std::mem::size_of::<*mut c_void>()