pub unsafe fn create<T: Send + 'static>(env: Env, v: T, finalizer: fn(Env, T)) -> Local {
    let v = Box::new(v);
    let mut result = MaybeUninit::uninit();

    let status = napi::create_external(
        env,
        Box::into_raw(v) as *mut _,
        Some(finalize_external::<T>),
        // Casting to `*const ()` is required to ensure the correct layout
        // https://rust-lang.github.io/unsafe-code-guidelines/layout/function-pointers.html
        finalizer as *const () as *mut _,
        result.as_mut_ptr(),
    );

    // `napi_create_external` will only fail if the VM is in a throwing state
    // or shutting down.
    assert_eq!(status, napi::Status::Ok);

    result.assume_init()
}
/// Creates a `napi_external` from a Rust type
Creates a `napi_external` from a Rust type
Creates a ` napi_external ` from a Rust type
pub unsafe fn create<T: Send + 'static>(env: Env, v: T, finalizer: fn(Env, T)) -> Local {
    let v = Box::new(v);
    let mut result = MaybeUninit::uninit();
    let status = napi::create_external(
        env,
        Box::into_raw(v) as *mut _,
        Some(finalize_external::<T>),
        // Casting to `*const ()` is required to ensure the correct layout
        // https://rust-lang.github.io/unsafe-code-guidelines/layout/function-pointers.html
        finalizer as *const () as *mut _,
        result.as_mut_ptr(),
    );
    // `napi_create_external` will only fail if the VM is in a throwing state
    // or shutting down.
    assert_eq!(status, napi::Status::Ok);
    result.assume_init()
}
pub unsafe fn create < T : Send + ' static > ( env : Env , v : T , finalizer : fn ( Env , T ) ) -> Local { let v = Box :: new ( v ) ; let mut result = MaybeUninit :: uninit ( ) ; let status = napi :: create_external ( env , Box :: into_raw ( v ) as * mut _ , Some ( finalize_external :: < T > ) , // Casting to `*const ()` is required to ensure the correct layout // https://rust-lang.github.io/unsafe-code-guidelines/layout/function-pointers.html finalizer as * const ( ) as * mut _ , result . as_mut_ptr ( ) , ) ; // `napi_create_external` will only fail if the VM is in a throwing state // or shutting down. assert_eq ! ( status napi Status Ok ) ; result . assume_init ( ) }
Creates a `napi_external` from a Rust type
Creates a ` napi_external ` from a Rust type
env
Env
v
T
finalizer
fn(Env, T)