Struct ra_ap_hir_ty::BoundVar
source · [−]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
'a
have a debruijn index of 1 and index 0 - the variable
'b
have a debruijn index of 1 and index 1 - the variable
'c
have a debruijn index of 0 and index 0 - the variable
'd
have 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: DebruijnIndex
Debruijn index, which identifies the binder.
index: usize
Index within the binder.
Implementations
sourceimpl BoundVar
impl BoundVar
sourcepub fn new(debruijn: DebruijnIndex, index: usize) -> BoundVar
pub fn new(debruijn: DebruijnIndex, index: usize) -> BoundVar
Creates a new bound variable.
sourcepub fn to_ty<I>(self, interner: I) -> Ty<I> where
I: Interner,
pub fn to_ty<I>(self, interner: I) -> Ty<I> where
I: Interner,
Casts the bound variable to a type.
sourcepub fn to_lifetime<I>(self, interner: I) -> Lifetime<I> where
I: Interner,
pub fn to_lifetime<I>(self, interner: I) -> Lifetime<I> where
I: Interner,
Wrap the bound variable in a lifetime.
sourcepub fn to_const<I>(self, interner: I, ty: Ty<I>) -> Const<I> where
I: Interner,
pub fn to_const<I>(self, interner: I, ty: Ty<I>) -> Const<I> where
I: Interner,
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) -> BoundVar
pub fn shifted_in(self) -> BoundVar
Adjusts the debruijn index (see DebruijnIndex::shifted_in
).
sourcepub fn shifted_in_from(self, outer_binder: DebruijnIndex) -> BoundVar
pub fn shifted_in_from(self, outer_binder: DebruijnIndex) -> BoundVar
Adjusts the debruijn index (see DebruijnIndex::shifted_in
).
sourcepub fn shifted_out(self) -> Option<BoundVar>
pub fn shifted_out(self) -> Option<BoundVar>
Adjusts the debruijn index (see DebruijnIndex::shifted_in
).
sourcepub fn shifted_out_to(self, outer_binder: DebruijnIndex) -> Option<BoundVar>
pub fn shifted_out_to(self, outer_binder: DebruijnIndex) -> Option<BoundVar>
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 HirDisplay for BoundVar
impl HirDisplay for BoundVar
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError>
sourcefn into_displayable<'a>(
&'a self,
db: &'a dyn HirDatabase,
max_size: Option<usize>,
omit_verbose_types: bool,
display_target: DisplayTarget
) -> HirDisplayWrapper<'a, Self> where
Self: Sized,
fn into_displayable<'a>(
&'a self,
db: &'a dyn HirDatabase,
max_size: Option<usize>,
omit_verbose_types: bool,
display_target: DisplayTarget
) -> HirDisplayWrapper<'a, Self> where
Self: Sized,
Returns a Display
able type that is human-readable.
sourcefn display<'a>(&'a self, db: &'a dyn HirDatabase) -> HirDisplayWrapper<'a, Self> where
Self: Sized,
fn display<'a>(&'a self, db: &'a dyn HirDatabase) -> HirDisplayWrapper<'a, Self> where
Self: Sized,
Returns a Display
able type that is human-readable.
Use this for showing types to the user (e.g. diagnostics) Read more
sourcefn display_truncated<'a>(
&'a self,
db: &'a dyn HirDatabase,
max_size: Option<usize>
) -> HirDisplayWrapper<'a, Self> where
Self: Sized,
fn display_truncated<'a>(
&'a self,
db: &'a dyn HirDatabase,
max_size: Option<usize>
) -> HirDisplayWrapper<'a, Self> where
Self: Sized,
Returns a Display
able type that is human-readable and tries to be succinct.
Use this for showing types to the user where space is constrained (e.g. doc popups) Read more
sourcefn display_source_code<'a>(
&'a self,
db: &'a dyn HirDatabase,
module_id: ModuleId
) -> Result<String, DisplaySourceCodeError>
fn display_source_code<'a>(
&'a self,
db: &'a dyn HirDatabase,
module_id: ModuleId
) -> Result<String, DisplaySourceCodeError>
Returns a String representation of self
that can be inserted into the given module.
Use this when generating code (e.g. assists) Read more
sourcefn display_test<'a>(
&'a self,
db: &'a dyn HirDatabase
) -> HirDisplayWrapper<'a, Self> where
Self: Sized,
fn display_test<'a>(
&'a self,
db: &'a dyn HirDatabase
) -> HirDisplayWrapper<'a, Self> where
Self: Sized,
Returns a String representation of self
for test purposes
sourceimpl Ord for BoundVar
impl Ord for BoundVar
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>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl 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 T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Cast for T
impl<T> Cast for T
sourcefn cast<U>(self, interner: <U as HasInterner>::Interner) -> U where
Self: CastTo<U>,
U: HasInterner,
fn cast<U>(self, interner: <U as HasInterner>::Interner) -> U where
Self: CastTo<U>,
U: HasInterner,
Cast a value to type U
using CastTo
.
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more