pub struct Environment { /* private fields */ }Expand description
Scoped variable environment with push/pop semantics.
Variables are looked up from innermost scope outward.
define always creates in the current (innermost) scope.
set updates the first scope where the variable exists.
Implementations§
Source§impl Environment
impl Environment
Sourcepub fn push_scope(&mut self)
pub fn push_scope(&mut self)
Push a new scope (for action bodies, let blocks, etc.).
Sourcepub fn define(&mut self, name: &str, value: Value)
pub fn define(&mut self, name: &str, value: Value)
Define a variable in the current (innermost) scope.
Sourcepub fn get(&self, name: &str) -> Option<&Value>
pub fn get(&self, name: &str) -> Option<&Value>
Look up a variable, searching from innermost to outermost scope.
Sourcepub fn set(&mut self, name: &str, value: Value) -> bool
pub fn set(&mut self, name: &str, value: Value) -> bool
Update a variable in the first scope where it exists.
Returns true if found and updated, false if not found.
Sourcepub fn global_bindings(&self) -> &BTreeMap<String, Value>
pub fn global_bindings(&self) -> &BTreeMap<String, Value>
Get all bindings in the global (outermost) scope. Used for capturing state.
Sourcepub fn restore_global(&mut self, bindings: BTreeMap<String, Value>)
pub fn restore_global(&mut self, bindings: BTreeMap<String, Value>)
Replace all bindings in the global scope (for rollback).
Trait Implementations§
Source§impl Clone for Environment
impl Clone for Environment
Source§fn clone(&self) -> Environment
fn clone(&self) -> Environment
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 Environment
impl Debug for Environment
Auto Trait Implementations§
impl Freeze for Environment
impl !RefUnwindSafe for Environment
impl Send for Environment
impl Sync for Environment
impl Unpin for Environment
impl !UnwindSafe for Environment
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