pub struct BindingStack<T> {
stack: Vec<T>,
}
Expand description
A stack of values corresponding to nested binders. Each binder introduces an entry in this
stack, with the entry as index 0
being the innermost binder. This is indexed by
DeBruijnId
s.
Most methods assume that the stack is non-empty and panic if not.
Fields§
§stack: Vec<T>
The stack, stored in reverse. We push/pop to the end of the Vec
, and the last pushed
value (i.e. the end of the vec) is considered index 0.
Implementations§
source§impl<T> BindingStack<T>
impl<T> BindingStack<T>
pub fn new(x: T) -> Self
pub fn is_empty(&self) -> bool
pub fn len(&self) -> usize
pub fn depth(&self) -> DeBruijnId
sourcepub fn as_bound_var<Id>(&self, var: DeBruijnVar<Id>) -> (DeBruijnId, Id)
pub fn as_bound_var<Id>(&self, var: DeBruijnVar<Id>) -> (DeBruijnId, Id)
Map a bound variable to ids binding depth.
pub fn push(&mut self, x: T)
pub fn pop(&mut self) -> Option<T>
sourcefn real_index(&self, id: DeBruijnId) -> Option<usize>
fn real_index(&self, id: DeBruijnId) -> Option<usize>
Helper that computes the real index into self.stack
.
pub fn get(&self, id: DeBruijnId) -> Option<&T>
pub fn get_var<'a, Id: Idx, Inner>(
&'a self,
var: DeBruijnVar<Id>,
) -> Option<&'a Inner::Output>where
T: Borrow<Inner>,
Inner: HasVectorOf<Id> + 'a,
pub fn get_mut(&mut self, id: DeBruijnId) -> Option<&mut T>
sourcepub fn iter(
&self,
) -> impl Iterator<Item = &T> + DoubleEndedIterator + ExactSizeIterator
pub fn iter( &self, ) -> impl Iterator<Item = &T> + DoubleEndedIterator + ExactSizeIterator
Iterate over the binding levels, from the innermost (0) out.
sourcepub fn iter_enumerated(
&self,
) -> impl Iterator<Item = (DeBruijnId, &T)> + DoubleEndedIterator + ExactSizeIterator
pub fn iter_enumerated( &self, ) -> impl Iterator<Item = (DeBruijnId, &T)> + DoubleEndedIterator + ExactSizeIterator
Iterate over the binding levels, from the innermost (0) out.
pub fn map_ref<'a, U>(&'a self, f: impl FnMut(&'a T) -> U) -> BindingStack<U>
pub fn innermost(&self) -> &T
pub fn innermost_mut(&mut self) -> &mut T
pub fn outermost(&self) -> &T
pub fn outermost_mut(&mut self) -> &mut T
Trait Implementations§
source§impl<T: Clone> Clone for BindingStack<T>
impl<T: Clone> Clone for BindingStack<T>
source§fn clone(&self) -> BindingStack<T>
fn clone(&self) -> BindingStack<T>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<T: Debug> Debug for BindingStack<T>
impl<T: Debug> Debug for BindingStack<T>
source§impl<T> Default for BindingStack<T>
impl<T> Default for BindingStack<T>
source§impl<T: Hash> Hash for BindingStack<T>
impl<T: Hash> Hash for BindingStack<T>
source§impl<T> Index<DeBruijnId> for BindingStack<T>
impl<T> Index<DeBruijnId> for BindingStack<T>
source§impl<T> IndexMut<DeBruijnId> for BindingStack<T>
impl<T> IndexMut<DeBruijnId> for BindingStack<T>
Auto Trait Implementations§
impl<T> Freeze for BindingStack<T>
impl<T> RefUnwindSafe for BindingStack<T>where
T: RefUnwindSafe,
impl<T> Send for BindingStack<T>where
T: Send,
impl<T> Sync for BindingStack<T>where
T: Sync,
impl<T> Unpin for BindingStack<T>where
T: Unpin,
impl<T> UnwindSafe for BindingStack<T>where
T: UnwindSafe,
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)§impl<I, T> ExtractContext<I, ()> for T
impl<I, T> ExtractContext<I, ()> for T
§fn extract_context(self, _original_input: I)
fn extract_context(self, _original_input: I)
Given the context attached to a nom error, and given the original
input to the nom parser, extract more the useful context information. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<I> RecreateContext<I> for I
impl<I> RecreateContext<I> for I
§fn recreate_context(_original_input: I, tail: I) -> I
fn recreate_context(_original_input: I, tail: I) -> I
Given the original input, as well as the context reported by nom,
recreate a context in the original string where the error occurred. Read more