pub struct Env {
pub bindings: Rc<RefCell<HashMap<Spur, Value>>>,
pub parent: Option<Rc<Env>>,
pub version: Cell<u64>,
}Expand description
A Sema environment: a chain of scopes with bindings.
Fields§
§bindings: Rc<RefCell<HashMap<Spur, Value>>>§parent: Option<Rc<Env>>§version: Cell<u64>Implementations§
Source§impl Env
impl Env
pub fn new() -> Self
pub fn with_parent(parent: Rc<Env>) -> Self
pub fn get(&self, name: Spur) -> Option<Value>
pub fn get_str(&self, name: &str) -> Option<Value>
pub fn set(&self, name: Spur, val: Value)
pub fn set_str(&self, name: &str, val: Value)
Sourcepub fn update(&self, name: Spur, val: Value)
pub fn update(&self, name: Spur, val: Value)
Update a binding that already exists in the current scope.
Sourcepub fn take(&self, name: Spur) -> Option<Value>
pub fn take(&self, name: Spur) -> Option<Value>
Remove and return a binding from the current scope only.
Sourcepub fn take_anywhere(&self, name: Spur) -> Option<Value>
pub fn take_anywhere(&self, name: Spur) -> Option<Value>
Remove and return a binding from any scope in the parent chain.
Sourcepub fn set_existing(&self, name: Spur, val: Value) -> bool
pub fn set_existing(&self, name: Spur, val: Value) -> bool
Set a variable in the scope where it’s defined (for set!).
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Env
impl !RefUnwindSafe for Env
impl !Send for Env
impl !Sync for Env
impl Unpin for Env
impl UnsafeUnpin for Env
impl !UnwindSafe for Env
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