mirror of
https://github.com/napi-rs/napi-rs.git
synced 2025-12-08 19:56:07 +00:00
chore(napi): env doesn't need to be mut (#2292)
This commit is contained in:
parent
9a6f01a20c
commit
eba0b52c59
@ -442,12 +442,10 @@ impl NapiStruct {
|
||||
|
||||
let finalize_trait = if class.use_custom_finalize {
|
||||
quote! {}
|
||||
} else if self.has_lifetime {
|
||||
quote! { impl <'_javascript_function_scope> napi::bindgen_prelude::ObjectFinalize for #name<'_javascript_function_scope> {} }
|
||||
} else {
|
||||
if self.has_lifetime {
|
||||
quote! { impl <'_javascript_function_scope> napi::bindgen_prelude::ObjectFinalize for #name<'_javascript_function_scope> {} }
|
||||
} else {
|
||||
quote! { impl napi::bindgen_prelude::ObjectFinalize for #name {} }
|
||||
}
|
||||
quote! { impl napi::bindgen_prelude::ObjectFinalize for #name {} }
|
||||
};
|
||||
|
||||
let to_napi_value_impl = if self.has_lifetime {
|
||||
|
||||
@ -24,7 +24,7 @@ impl<'env, T: 'env> ClassInstance<'env, T> {
|
||||
Self { value, inner }
|
||||
}
|
||||
|
||||
pub fn as_object(&self, env: Env) -> Object {
|
||||
pub fn as_object(&self, env: &Env) -> Object {
|
||||
unsafe { Object::from_raw_unchecked(env.raw(), self.value) }
|
||||
}
|
||||
}
|
||||
|
||||
@ -402,7 +402,7 @@ impl Env {
|
||||
/// Registering externally allocated memory will trigger global garbage collections more often than it would otherwise.
|
||||
///
|
||||
/// ***ATTENTION ⚠️***, do not use this with `create_buffer_with_data/create_arraybuffer_with_data`, since these two functions already called the `adjust_external_memory` internal.
|
||||
pub fn adjust_external_memory(&mut self, size: i64) -> Result<i64> {
|
||||
pub fn adjust_external_memory(&self, size: i64) -> Result<i64> {
|
||||
let mut changed = 0i64;
|
||||
check_status!(unsafe { sys::napi_adjust_external_memory(self.0, size, &mut changed) })?;
|
||||
Ok(changed)
|
||||
@ -410,7 +410,7 @@ impl Env {
|
||||
|
||||
#[cfg(target_family = "wasm")]
|
||||
#[allow(unused_variables)]
|
||||
pub fn adjust_external_memory(&mut self, size: i64) -> Result<i64> {
|
||||
pub fn adjust_external_memory(&self, size: i64) -> Result<i64> {
|
||||
Ok(0)
|
||||
}
|
||||
|
||||
@ -1025,7 +1025,7 @@ impl Env {
|
||||
|
||||
#[cfg(feature = "napi3")]
|
||||
pub fn add_env_cleanup_hook<T, F>(
|
||||
&mut self,
|
||||
&self,
|
||||
cleanup_data: T,
|
||||
cleanup_fn: F,
|
||||
) -> Result<CleanupEnvHook<T>>
|
||||
@ -1049,7 +1049,7 @@ impl Env {
|
||||
}
|
||||
|
||||
#[cfg(feature = "napi3")]
|
||||
pub fn remove_env_cleanup_hook<T>(&mut self, hook: CleanupEnvHook<T>) -> Result<()>
|
||||
pub fn remove_env_cleanup_hook<T>(&self, hook: CleanupEnvHook<T>) -> Result<()>
|
||||
where
|
||||
T: 'static,
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user