feat(napi): support external deref/derefMut
This commit is contained in:
parent
212bbe285e
commit
0aa7cd3d32
2 changed files with 20 additions and 3 deletions
crates/napi/src/bindgen_runtime/js_values
|
@ -1,4 +1,7 @@
|
|||
use std::any::TypeId;
|
||||
use std::{
|
||||
any::TypeId,
|
||||
ops::{Deref, DerefMut},
|
||||
};
|
||||
|
||||
use crate::{check_status, Error, Status, TaggedObject};
|
||||
|
||||
|
@ -73,6 +76,20 @@ impl<T: 'static> AsMut<T> for External<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: 'static> Deref for External<T> {
|
||||
type Target = T;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
self.as_ref()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: 'static> DerefMut for External<T> {
|
||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||
self.as_mut()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: 'static> ToNapiValue for External<T> {
|
||||
unsafe fn to_napi_value(
|
||||
env: napi_sys::napi_env,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue