pub struct BoundVar {
pub debruijn: DebruijnIndex,
pub index: usize,
}Expand description
Identifies a particular bound variable within a binder.
Variables are identified by the combination of a DebruijnIndex,
which identifies the binder, and an index within that binder.
Consider this case:
forall<'a, 'b> { forall<'c, 'd> { ... } }Within the ... term:
- the variable
'ahave a debruijn index of 1 and index 0 - the variable
'bhave a debruijn index of 1 and index 1 - the variable
'chave a debruijn index of 0 and index 0 - the variable
'dhave a debruijn index of 0 and index 1
The variables 'a and 'b both have debruijn index of 1 because,
counting out, they are the 2nd binder enclosing .... The indices
identify the location within that binder.
The variables 'c and 'd both have debruijn index of 0 because
they appear in the innermost binder enclosing the .... The
indices identify the location within that binder.
Fields
debruijn: DebruijnIndexDebruijn index, which identifies the binder.
index: usizeIndex within the binder.
Implementations
sourceimpl BoundVar
impl BoundVar
sourcepub fn new(debruijn: DebruijnIndex, index: usize) -> Self
pub fn new(debruijn: DebruijnIndex, index: usize) -> Self
Creates a new bound variable.
sourcepub fn to_lifetime<I: Interner>(self, interner: I) -> Lifetime<I>
pub fn to_lifetime<I: Interner>(self, interner: I) -> Lifetime<I>
Wrap the bound variable in a lifetime.
sourcepub fn to_const<I: Interner>(self, interner: I, ty: Ty<I>) -> Const<I>
pub fn to_const<I: Interner>(self, interner: I, ty: Ty<I>) -> Const<I>
Wraps the bound variable in a constant.
sourcepub fn bound_within(self, outer_binder: DebruijnIndex) -> bool
pub fn bound_within(self, outer_binder: DebruijnIndex) -> bool
True if this variable is bound within the amount innermost binders.
sourcepub fn shifted_in(self) -> Self
pub fn shifted_in(self) -> Self
Adjusts the debruijn index (see DebruijnIndex::shifted_in).
sourcepub fn shifted_in_from(self, outer_binder: DebruijnIndex) -> Self
pub fn shifted_in_from(self, outer_binder: DebruijnIndex) -> Self
Adjusts the debruijn index (see DebruijnIndex::shifted_in).
sourcepub fn shifted_out(self) -> Option<Self>
pub fn shifted_out(self) -> Option<Self>
Adjusts the debruijn index (see DebruijnIndex::shifted_in).
sourcepub fn shifted_out_to(self, outer_binder: DebruijnIndex) -> Option<Self>
pub fn shifted_out_to(self, outer_binder: DebruijnIndex) -> Option<Self>
Adjusts the debruijn index (see DebruijnIndex::shifted_in).
sourcepub fn index_if_innermost(self) -> Option<usize>
pub fn index_if_innermost(self) -> Option<usize>
Return the index of the bound variable, but only if it is bound
at the innermost binder. Otherwise, returns None.
sourcepub fn index_if_bound_at(self, debruijn: DebruijnIndex) -> Option<usize>
pub fn index_if_bound_at(self, debruijn: DebruijnIndex) -> Option<usize>
Return the index of the bound variable, but only if it is bound
at the innermost binder. Otherwise, returns None.
Trait Implementations
sourceimpl Ord for BoundVar
impl Ord for BoundVar
1.21.0 · sourcefn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 · sourcefn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
sourceimpl PartialOrd<BoundVar> for BoundVar
impl PartialOrd<BoundVar> for BoundVar
sourcefn partial_cmp(&self, other: &BoundVar) -> Option<Ordering>
fn partial_cmp(&self, other: &BoundVar) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read moreimpl Copy for BoundVar
impl Eq for BoundVar
impl StructuralEq for BoundVar
impl StructuralPartialEq for BoundVar
Auto Trait Implementations
impl RefUnwindSafe for BoundVar
impl Send for BoundVar
impl Sync for BoundVar
impl Unpin for BoundVar
impl UnwindSafe for BoundVar
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
sourceimpl<T> Cast for T
impl<T> Cast for T
sourcefn cast<U>(self, interner: U::Interner) -> Uwhere
Self: CastTo<U>,
U: HasInterner,
fn cast<U>(self, interner: U::Interner) -> Uwhere
Self: CastTo<U>,
U: HasInterner,
U using CastTo.