Struct chalk_ir::BoundVar[][src]

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[src]

pub fn new(debruijn: DebruijnIndex, index: usize) -> Self[src]

Creates a new bound variable.

pub fn to_ty<I: Interner>(self, interner: &I) -> Ty<I>[src]

Casts the bound variable to a type.

pub fn to_lifetime<I: Interner>(self, interner: &I) -> Lifetime<I>[src]

Wrap the bound variable in a lifetime.

pub fn to_const<I: Interner>(self, interner: &I, ty: Ty<I>) -> Const<I>[src]

Wraps the bound variable in a constant.

pub fn bound_within(self, outer_binder: DebruijnIndex) -> bool[src]

True if this variable is bound within the amount innermost binders.

#[must_use]
pub fn shifted_in(self) -> Self
[src]

Adjusts the debruijn index (see DebruijnIndex::shifted_in).

#[must_use]
pub fn shifted_in_from(self, outer_binder: DebruijnIndex) -> Self
[src]

Adjusts the debruijn index (see DebruijnIndex::shifted_in).

#[must_use]
pub fn shifted_out(self) -> Option<Self>
[src]

Adjusts the debruijn index (see DebruijnIndex::shifted_in).

#[must_use]
pub fn shifted_out_to(self, outer_binder: DebruijnIndex) -> Option<Self>
[src]

Adjusts the debruijn index (see DebruijnIndex::shifted_in).

pub fn index_if_innermost(self) -> Option<usize>[src]

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>[src]

Return the index of the bound variable, but only if it is bound at the innermost binder. Otherwise, returns None.

Trait Implementations

impl Clone for BoundVar[src]

fn clone(&self) -> BoundVar[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for BoundVar[src]

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), Error>[src]

Formats the value using the given formatter. Read more

impl Hash for BoundVar[src]

fn hash<__H: Hasher>(&self, state: &mut __H)[src]

Feeds this value into the given Hasher. Read more

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

Feeds a slice of this type into the given Hasher. Read more

impl Ord for BoundVar[src]

fn cmp(&self, other: &BoundVar) -> Ordering[src]

This method returns an Ordering between self and other. Read more

#[must_use]
fn max(self, other: Self) -> Self
1.21.0[src]

Compares and returns the maximum of two values. Read more

#[must_use]
fn min(self, other: Self) -> Self
1.21.0[src]

Compares and returns the minimum of two values. Read more

#[must_use]
fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]

Restrict a value to a certain interval. Read more

impl PartialEq<BoundVar> for BoundVar[src]

fn eq(&self, other: &BoundVar) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &BoundVar) -> bool[src]

This method tests for !=.

impl PartialOrd<BoundVar> for BoundVar[src]

fn partial_cmp(&self, other: &BoundVar) -> Option<Ordering>[src]

This method returns an ordering between self and other values if one exists. Read more

#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests less than (for self and other) and is used by the < operator. Read more

#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl Copy for BoundVar[src]

impl Eq for BoundVar[src]

impl StructuralEq for BoundVar[src]

impl StructuralPartialEq for BoundVar[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> Cast for T[src]

fn cast<U>(self, interner: &U::Interner) -> U where
    Self: CastTo<U>,
    U: HasInterner
[src]

Cast a value to type U using CastTo.

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.