pub struct Context { /* private fields */ }Expand description
Local typing context
Uses de Bruijn indices: variable #0 is the most recently bound, #1 is the one before that, etc.
Implementations§
Source§impl Context
impl Context
Sourcepub fn push(&mut self, entry: ContextEntry)
pub fn push(&mut self, entry: ContextEntry)
Push a new binding onto the context
Sourcepub fn pop(&mut self) -> Option<ContextEntry>
pub fn pop(&mut self) -> Option<ContextEntry>
Pop the most recent binding
Sourcepub fn lookup(&self, index: u32) -> Option<&ContextEntry>
pub fn lookup(&self, index: u32) -> Option<&ContextEntry>
Look up a variable by de Bruijn index
Index 0 refers to the most recently bound variable
Sourcepub fn type_of(&self, index: u32) -> Option<TermId>
pub fn type_of(&self, index: u32) -> Option<TermId>
Get the type of a variable by de Bruijn index
Sourcepub fn value_of(&self, index: u32) -> Option<TermId>
pub fn value_of(&self, index: u32) -> Option<TermId>
Get the value of a variable (if it’s a let binding)
Sourcepub fn extend(&mut self, entries: impl IntoIterator<Item = ContextEntry>)
pub fn extend(&mut self, entries: impl IntoIterator<Item = ContextEntry>)
Extend the context with multiple entries
Sourcepub fn with_entries(
&self,
entries: impl IntoIterator<Item = ContextEntry>,
) -> Self
pub fn with_entries( &self, entries: impl IntoIterator<Item = ContextEntry>, ) -> Self
Create a new context by extending this one
Sourcepub fn entries(&self) -> &[ContextEntry]
pub fn entries(&self) -> &[ContextEntry]
Get all entries (for iteration)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Context
impl RefUnwindSafe for Context
impl Send for Context
impl Sync for Context
impl Unpin for Context
impl UnwindSafe for Context
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