diff --git a/crates/neon/src/context/internal.rs b/crates/neon/src/context/internal.rs index f1b8f49bb..bf872d2e5 100644 --- a/crates/neon/src/context/internal.rs +++ b/crates/neon/src/context/internal.rs @@ -1,7 +1,7 @@ use std::{cell::RefCell, ffi::c_void, mem::MaybeUninit}; use crate::{ - context::{Cx, ModuleContext}, + context::ModuleContext, handle::Handle, result::NeonResult, sys::{self, raw}, @@ -46,10 +46,8 @@ impl Env { } } -pub trait ContextInternal<'cx>: AsRef> + AsMut> + Sized { - fn env(&self) -> Env { - self.as_ref().env() - } +pub trait ContextInternal<'cx>: Sized { + fn env(&self) -> Env; } fn default_main(mut cx: ModuleContext) -> NeonResult<()> { diff --git a/crates/neon/src/context/mod.rs b/crates/neon/src/context/mod.rs index 9490757aa..6c90e7cd6 100644 --- a/crates/neon/src/context/mod.rs +++ b/crates/neon/src/context/mod.rs @@ -233,26 +233,14 @@ impl<'cx> Cx<'cx> { _phantom_inner: PhantomData, }) } +} +impl<'cx> ContextInternal<'cx> for Cx<'cx> { fn env(&self) -> Env { self.env } } -impl<'cx> AsRef> for Cx<'cx> { - fn as_ref(&self) -> &Cx<'cx> { - self - } -} - -impl<'cx> AsMut> for Cx<'cx> { - fn as_mut(&mut self) -> &mut Cx<'cx> { - self - } -} - -impl<'cx> ContextInternal<'cx> for Cx<'cx> {} - impl<'cx> Context<'cx> for Cx<'cx> {} #[repr(C)] @@ -644,18 +632,6 @@ impl<'cx> DerefMut for ModuleContext<'cx> { } } -impl<'cx> AsRef> for ModuleContext<'cx> { - fn as_ref(&self) -> &Cx<'cx> { - self - } -} - -impl<'cx> AsMut> for ModuleContext<'cx> { - fn as_mut(&mut self) -> &mut Cx<'cx> { - self - } -} - impl<'cx> UnwindSafe for ModuleContext<'cx> {} impl<'cx> ModuleContext<'cx> { @@ -708,7 +684,11 @@ impl<'cx> ModuleContext<'cx> { } } -impl<'cx> ContextInternal<'cx> for ModuleContext<'cx> {} +impl<'cx> ContextInternal<'cx> for ModuleContext<'cx> { + fn env(&self) -> Env { + self.cx.env + } +} impl<'cx> Context<'cx> for ModuleContext<'cx> {} @@ -736,18 +716,6 @@ impl<'cx> DerefMut for FunctionContext<'cx> { } } -impl<'cx> AsRef> for FunctionContext<'cx> { - fn as_ref(&self) -> &Cx<'cx> { - self - } -} - -impl<'cx> AsMut> for FunctionContext<'cx> { - fn as_mut(&mut self) -> &mut Cx<'cx> { - self - } -} - impl<'cx> UnwindSafe for FunctionContext<'cx> {} impl<'cx> FunctionContext<'cx> { @@ -862,6 +830,10 @@ impl<'cx> FunctionContext<'cx> { } } -impl<'cx> ContextInternal<'cx> for FunctionContext<'cx> {} +impl<'cx> ContextInternal<'cx> for FunctionContext<'cx> { + fn env(&self) -> Env { + self.cx.env + } +} impl<'cx> Context<'cx> for FunctionContext<'cx> {}