Struct Environment

Source
pub struct Environment<Name: Eq + Hash, T> { /* private fields */ }
Expand description

A scoped set of bindings between names and values.

Implementations§

Source§

impl<Name: Eq + Hash, T> Environment<Name, T>

Source

pub fn new() -> Self

Constructs a new context with a base scope that further scopes can be pushed and popped on top of.

Source

pub fn push(&mut self)

Creates a new scope.

Source

pub fn pop(&mut self) -> bool

Removes all bindings in the most recent scope, returning true unless there are no scopes beside the base scope.

Source

pub fn bind(&mut self, name: Name, value: T) -> Option<T>

Binds name to value in the top scope, returning Some(previous_value) if previous_value had previously been bound to name, or None.

Source

pub fn bind_base(&mut self, name: Name, value: T) -> Option<T>

Binds name to value in the base scope.

@see Environment::bind

Source

pub fn find(&self, name: Name) -> Option<&T>

Finds the bound value for name in the highest scope possible.

Trait Implementations§

Source§

impl<Name: Eq + Hash, T> Default for Environment<Name, T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<Name, T> Freeze for Environment<Name, T>

§

impl<Name, T> RefUnwindSafe for Environment<Name, T>
where Name: RefUnwindSafe, T: RefUnwindSafe,

§

impl<Name, T> Send for Environment<Name, T>
where Name: Send, T: Send,

§

impl<Name, T> Sync for Environment<Name, T>
where Name: Sync, T: Sync,

§

impl<Name, T> Unpin for Environment<Name, T>
where Name: Unpin, T: Unpin,

§

impl<Name, T> UnwindSafe for Environment<Name, T>
where Name: UnwindSafe, T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.