pub struct Environment { /* private fields */ }
Expand description
The environment in which lambda terms get evaluated.
There are two possibilities to create an instance of Environment
:
Environment::new()
- creates an empty environment.Environment::default()
- creates an environment containing predefined bindings to all the builtin standard terms, combinators and data encoding terms.
Implementations§
Source§impl Environment
impl Environment
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new empty environment.
The empty environment does not contain any bindings at all. If you want
to create an environment with predefined bindings to all the builtin
standard terms, combinators and data encodings use the
Environment::default()
function.
Sourcepub fn insert_binding(&mut self, binding: Binding)
pub fn insert_binding(&mut self, binding: Binding)
Adds the given binding to this environment.
Sourcepub fn bind(&mut self, name: VarName, term: Term) -> Option<Term>
pub fn bind(&mut self, name: VarName, term: Term) -> Option<Term>
Adds a new binding of the given term to the given name to this environment.
Sourcepub fn unbind(&mut self, name: &VarName) -> Option<Term>
pub fn unbind(&mut self, name: &VarName) -> Option<Term>
Removes the binding to the given name from this environment and returns the bound term if such a binding previously existed.
Sourcepub fn clear_bindings(&mut self)
pub fn clear_bindings(&mut self)
Removes all bindings from this environment.
Sourcepub fn bindings(&self) -> impl Iterator<Item = (&VarName, &Term)>
pub fn bindings(&self) -> impl Iterator<Item = (&VarName, &Term)>
Returns an iterator over all bindings defined in this environment.
The iterator issues the items in an arbitrary order.
Sourcepub fn into_bindings(self) -> impl Iterator<Item = Binding>
pub fn into_bindings(self) -> impl Iterator<Item = Binding>
Returns an iterator over all bindings defined in this environment.
Sourcepub fn lookup_term(&self, name: &VarName) -> Option<&Term>
pub fn lookup_term(&self, name: &VarName) -> Option<&Term>
Looks up the binding for a name and returns a reference to the bound term if a binding exists for the given name.
Trait Implementations§
Source§impl Clone for Environment
impl Clone for Environment
Source§fn clone(&self) -> Environment
fn clone(&self) -> Environment
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for Environment
impl Debug for Environment
Source§impl Default for Environment
impl Default for Environment
Source§impl Extend<(VarName, Term)> for Environment
impl Extend<(VarName, Term)> for Environment
Source§fn extend<I: IntoIterator<Item = (VarName, Term)>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = (VarName, Term)>>(&mut self, iter: I)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Source§impl Extend<Binding> for Environment
impl Extend<Binding> for Environment
Source§fn extend<I: IntoIterator<Item = Binding>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = Binding>>(&mut self, iter: I)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)