Skip to main content

LocalEnv

Struct LocalEnv 

Source
pub struct LocalEnv<'a, V> { /* private fields */ }
Expand description

A layered lexical environment for HIR locals.

Each binder (for-comp, scan, unfold, match arm) layers a child frame holding its few bindings over the enclosing environment instead of cloning the full local map; lookup walks the parent chain. LocalIds are unique within one lowered body, so frames never shadow one another — the chain is purely an ownership layering, and nested binders cost O(own bindings) instead of O(visible locals).

Implementations§

Source§

impl<'a, V> LocalEnv<'a, V>

Source

pub const fn root() -> Self

Create an empty root environment.

Source

pub const fn from_bindings(bindings: Vec<(LocalId, V)>) -> Self

Create a root environment holding the given bindings.

Source

pub const fn child<'b>(&'b self, bindings: Vec<(LocalId, V)>) -> LocalEnv<'b, V>
where 'a: 'b,

Layer a child frame holding bindings over this environment.

Source

pub fn get(&self, id: LocalId) -> Option<&V>

Look up a local by its lexical identity, innermost frame first.

Source

pub fn bind(&mut self, id: LocalId, value: V)

Bind or update a local in this frame.

Iterating binders (for-comp elements, scan/unfold steps) rebind the same LocalId once per iteration without growing the frame.

Trait Implementations§

Source§

impl<'a, V: Debug> Debug for LocalEnv<'a, V>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<V> Default for LocalEnv<'_, V>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<'a, V> Freeze for LocalEnv<'a, V>

§

impl<'a, V> RefUnwindSafe for LocalEnv<'a, V>
where V: RefUnwindSafe,

§

impl<'a, V> Send for LocalEnv<'a, V>
where V: Send + Sync,

§

impl<'a, V> Sync for LocalEnv<'a, V>
where V: Sync,

§

impl<'a, V> Unpin for LocalEnv<'a, V>
where V: Unpin,

§

impl<'a, V> UnsafeUnpin for LocalEnv<'a, V>

§

impl<'a, V> UnwindSafe for LocalEnv<'a, V>

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.