pub struct TempEnvScope<'a> { /* private fields */ }Expand description
A scope guard for temporarily adding declarations to an environment.
Useful for checking declarations in a hypothetical context (e.g., inside
a section or namespace) without permanently mutating the environment.
NOTE: This struct borrows the environment mutably and removes the added declarations when dropped. This is a lightweight simulation for testing.
Implementations§
Source§impl<'a> TempEnvScope<'a>
impl<'a> TempEnvScope<'a>
Sourcepub fn new(env: &'a mut Environment) -> Self
pub fn new(env: &'a mut Environment) -> Self
Create a new temporary scope backed by env.
Sourcepub fn add(&mut self, decl: Declaration) -> Result<(), KernelError>
pub fn add(&mut self, decl: Declaration) -> Result<(), KernelError>
Add a declaration to the scope. Returns true on success.
Sourcepub fn env(&self) -> &Environment
pub fn env(&self) -> &Environment
Get a reference to the underlying environment.
Sourcepub fn env_mut(&mut self) -> &mut Environment
pub fn env_mut(&mut self) -> &mut Environment
Get a mutable reference to the underlying environment.
Auto Trait Implementations§
impl<'a> Freeze for TempEnvScope<'a>
impl<'a> RefUnwindSafe for TempEnvScope<'a>
impl<'a> Send for TempEnvScope<'a>
impl<'a> Sync for TempEnvScope<'a>
impl<'a> Unpin for TempEnvScope<'a>
impl<'a> UnsafeUnpin for TempEnvScope<'a>
impl<'a> !UnwindSafe for TempEnvScope<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more