Struct BoundVar
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§
§impl BoundVar
impl BoundVar
pub fn new(debruijn: DebruijnIndex, index: usize) -> BoundVar
pub fn new(debruijn: DebruijnIndex, index: usize) -> BoundVar
Creates a new bound variable.
pub 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.
pub 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.
pub 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.
pub 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.
pub fn shifted_in(self) -> BoundVar
pub fn shifted_in(self) -> BoundVar
Adjusts the debruijn index (see DebruijnIndex::shifted_in
).
pub 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
).
pub fn shifted_out(self) -> Option<BoundVar>
pub fn shifted_out(self) -> Option<BoundVar>
Adjusts the debruijn index (see DebruijnIndex::shifted_in
).
pub 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
).
pub 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
.
pub 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§
source§impl HirDisplay for BoundVar
impl HirDisplay for BoundVar
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError>
source§fn into_displayable<'a>(
&'a self,
db: &'a dyn HirDatabase,
max_size: Option<usize>,
limited_size: Option<usize>,
omit_verbose_types: bool,
display_target: DisplayTarget,
closure_style: ClosureStyle,
show_container_bounds: bool,
) -> HirDisplayWrapper<'a, Self>where
Self: Sized,
fn into_displayable<'a>(
&'a self,
db: &'a dyn HirDatabase,
max_size: Option<usize>,
limited_size: Option<usize>,
omit_verbose_types: bool,
display_target: DisplayTarget,
closure_style: ClosureStyle,
show_container_bounds: bool,
) -> HirDisplayWrapper<'a, Self>where
Self: Sized,
Display
able type that is human-readable.source§fn display<'a>(
&'a self,
db: &'a dyn HirDatabase,
edition: Edition,
) -> HirDisplayWrapper<'a, Self>where
Self: Sized,
fn display<'a>(
&'a self,
db: &'a dyn HirDatabase,
edition: Edition,
) -> HirDisplayWrapper<'a, Self>where
Self: Sized,
Display
able type that is human-readable.
Use this for showing types to the user (e.g. diagnostics)source§fn display_truncated<'a>(
&'a self,
db: &'a dyn HirDatabase,
max_size: Option<usize>,
edition: Edition,
) -> HirDisplayWrapper<'a, Self>where
Self: Sized,
fn display_truncated<'a>(
&'a self,
db: &'a dyn HirDatabase,
max_size: Option<usize>,
edition: Edition,
) -> HirDisplayWrapper<'a, Self>where
Self: Sized,
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)source§fn display_limited<'a>(
&'a self,
db: &'a dyn HirDatabase,
limited_size: Option<usize>,
edition: Edition,
) -> HirDisplayWrapper<'a, Self>where
Self: Sized,
fn display_limited<'a>(
&'a self,
db: &'a dyn HirDatabase,
limited_size: Option<usize>,
edition: Edition,
) -> HirDisplayWrapper<'a, Self>where
Self: Sized,
Display
able type that is human-readable and tries to limit the number of items inside.
Use this for showing definitions which may contain too many items, like trait
, struct
, enum
source§fn display_source_code<'a>(
&'a self,
db: &'a dyn HirDatabase,
module_id: ModuleId,
allow_opaque: bool,
) -> Result<String, DisplaySourceCodeError>
fn display_source_code<'a>( &'a self, db: &'a dyn HirDatabase, module_id: ModuleId, allow_opaque: bool, ) -> Result<String, DisplaySourceCodeError>
self
that can be inserted into the given module.
Use this when generating code (e.g. assists)source§fn 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,
self
for test purposessource§fn display_with_container_bounds<'a>(
&'a self,
db: &'a dyn HirDatabase,
show_container_bounds: bool,
edition: Edition,
) -> HirDisplayWrapper<'a, Self>where
Self: Sized,
fn display_with_container_bounds<'a>(
&'a self,
db: &'a dyn HirDatabase,
show_container_bounds: bool,
edition: Edition,
) -> HirDisplayWrapper<'a, Self>where
Self: Sized,
self
that shows the constraint from
the container for functions§impl Ord for BoundVar
impl Ord for BoundVar
§impl PartialOrd for BoundVar
impl PartialOrd for BoundVar
impl Copy for BoundVar
impl Eq for BoundVar
impl StructuralPartialEq for BoundVar
Auto Trait Implementations§
impl Freeze for BoundVar
impl RefUnwindSafe for BoundVar
impl Send for BoundVar
impl Sync for BoundVar
impl Unpin for BoundVar
impl UnwindSafe for BoundVar
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
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)
clone_to_uninit
)§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§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> ⓘ
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> ⓘ
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