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() -> Env
pub fn with_parent(parent: Rc<Env>) -> Env
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
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