pub struct Env(/* private fields */);Expand description
A persistent spine of chunks, each owning [base, base + vals.len()).
Extending a shared one links rather than copies: applying a closure always
shares its environment, so a flat copy-on-write vector copied every call.
Implementations§
Source§impl Env
impl Env
pub fn new(vals: Vec<Val>) -> Env
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn get(&self, i: usize) -> Option<&Val>
Sourcepub fn iter(&self) -> impl Iterator<Item = &Val> + '_
pub fn iter(&self) -> impl Iterator<Item = &Val> + '_
Yields bindings in de Bruijn order. Each step re-walks the spine, so this is for cold paths (structural equality, printing) only.
pub fn ptr_eq(a: &Env, b: &Env) -> bool
Sourcepub fn push(&self, val: Val) -> Env
pub fn push(&self, val: Val) -> Env
Always links: the caller holds only a borrow, so the existing chunk may not be disturbed.
Sourcepub fn frame(self, vals: Vec<Val>) -> Env
pub fn frame(self, vals: Vec<Val>) -> Env
A whole frame at once. Entering a closure binds self and arguments together, and a push apiece regrows the vector once per binding.
pub fn push_owned(self, val: Val) -> Env
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 !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