pub struct CapturedEnvironment {
pub bindings: HashMap<String, CapturedBinding>,
pub parent: Option<Box<CapturedEnvironment>>,
}Expand description
Captured environment for a closure
Fields§
§bindings: HashMap<String, CapturedBinding>Captured variable bindings
parent: Option<Box<CapturedEnvironment>>Parent environment (for nested closures)
Implementations§
Source§impl CapturedEnvironment
impl CapturedEnvironment
Sourcepub fn with_parent(parent: CapturedEnvironment) -> Self
pub fn with_parent(parent: CapturedEnvironment) -> Self
Create a new environment with a parent
Sourcepub fn capture(&mut self, name: String, value: ValueWord, kind: VarKind)
pub fn capture(&mut self, name: String, value: ValueWord, kind: VarKind)
Capture a variable from the current scope
Sourcepub fn lookup(&self, name: &str) -> Option<&CapturedBinding>
pub fn lookup(&self, name: &str) -> Option<&CapturedBinding>
Look up a captured variable
Sourcepub fn lookup_mut(&mut self, name: &str) -> Option<&mut CapturedBinding>
pub fn lookup_mut(&mut self, name: &str) -> Option<&mut CapturedBinding>
Look up a captured variable mutably
Sourcepub fn all_captured_names(&self) -> Vec<String>
pub fn all_captured_names(&self) -> Vec<String>
Get all captured variable names (including from parent scopes)
Trait Implementations§
Source§impl Clone for CapturedEnvironment
impl Clone for CapturedEnvironment
Source§fn clone(&self) -> CapturedEnvironment
fn clone(&self) -> CapturedEnvironment
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CapturedEnvironment
impl Debug for CapturedEnvironment
Source§impl Default for CapturedEnvironment
impl Default for CapturedEnvironment
Source§impl PartialEq for CapturedEnvironment
impl PartialEq for CapturedEnvironment
Auto Trait Implementations§
impl Freeze for CapturedEnvironment
impl RefUnwindSafe for CapturedEnvironment
impl Send for CapturedEnvironment
impl Sync for CapturedEnvironment
impl Unpin for CapturedEnvironment
impl UnsafeUnpin for CapturedEnvironment
impl UnwindSafe for CapturedEnvironment
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more