Type Alias Lifetime

Source
pub type Lifetime = Lifetime<Interner>;

Aliased Type§

struct Lifetime { /* private fields */ }

Implementations

§

impl<I> Lifetime<I>
where I: Interner,

pub fn new(interner: I, data: impl CastTo<LifetimeData<I>>) -> Lifetime<I>

Create a lifetime from lifetime data (or something that can be cast to lifetime data).

pub fn interned(&self) -> &<I as Interner>::InternedLifetime

Gets the interned value.

pub fn data(&self, interner: I) -> &LifetimeData<I>

Gets the lifetime data.

pub fn bound_var(&self, interner: I) -> Option<BoundVar>

If this is a Lifetime::BoundVar(d), returns Some(d) else None.

pub fn inference_var(&self, interner: I) -> Option<InferenceVar>

If this is a Lifetime::InferenceVar(d), returns Some(d) else None.

pub fn needs_shift(&self, interner: I) -> bool

True if this lifetime is a “bound” lifetime, and hence needs to be shifted across binders. Meant for debug assertions.

Trait Implementations§

Source§

impl HirDisplay for Lifetime

Source§

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, display_kind: DisplayKind, closure_style: ClosureStyle, show_container_bounds: bool, ) -> HirDisplayWrapper<'a, Self>
where Self: Sized,

Returns a Displayable type that is human-readable.
Source§

fn display<'a>( &'a self, db: &'a dyn HirDatabase, display_target: DisplayTarget, ) -> HirDisplayWrapper<'a, Self>
where Self: Sized,

Returns a Displayable 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>, display_target: DisplayTarget, ) -> HirDisplayWrapper<'a, Self>
where Self: Sized,

Returns a Displayable 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>, display_target: DisplayTarget, ) -> HirDisplayWrapper<'a, Self>
where Self: Sized,

Returns a Displayable 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>

Returns a String representation of 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, display_target: DisplayTarget, ) -> HirDisplayWrapper<'a, Self>
where Self: Sized,

Returns a String representation of self for test purposes
Source§

fn display_with_container_bounds<'a>( &'a self, db: &'a dyn HirDatabase, show_container_bounds: bool, display_target: DisplayTarget, ) -> HirDisplayWrapper<'a, Self>
where Self: Sized,

Returns a String representation of self that shows the constraint from the container for functions
§

impl<I> CastTo<GenericArg<I>> for Lifetime<I>
where I: Interner,

§

fn cast_to(self, interner: I) -> GenericArg<I>

Cast a value to type T.
§

impl<I> Clone for Lifetime<I>
where I: Clone + Interner, <I as Interner>::InternedLifetime: Clone,

§

fn clone(&self) -> Lifetime<I>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl<I> Debug for Lifetime<I>
where I: Interner,

§

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

Formats the value using the given formatter. Read more
§

impl<I> HasInterner for Lifetime<I>
where I: Interner,

§

type Interner = I

The interner associated with the type.
§

impl<I> Hash for Lifetime<I>
where I: Hash + Interner, <I as Interner>::InternedLifetime: Hash,

§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

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

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

impl<I> Ord for Lifetime<I>
where I: Ord + Interner, <I as Interner>::InternedLifetime: Ord,

§

fn cmp(&self, other: &Lifetime<I>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
§

impl<I> PartialEq for Lifetime<I>
where I: PartialEq + Interner, <I as Interner>::InternedLifetime: PartialEq,

§

fn eq(&self, other: &Lifetime<I>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl<I> PartialOrd for Lifetime<I>
where I: PartialOrd + Interner, <I as Interner>::InternedLifetime: PartialOrd,

§

fn partial_cmp(&self, other: &Lifetime<I>) -> Option<Ordering>

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

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

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

impl<I> TypeFoldable<I> for Lifetime<I>
where I: Interner,

“Folding” a lifetime invokes the fold_lifetime method on the folder; this usually (in turn) invokes super_fold_lifetime to fold the individual parts.

§

fn try_fold_with<E>( self, folder: &mut dyn FallibleTypeFolder<I, Error = E>, outer_binder: DebruijnIndex, ) -> Result<Lifetime<I>, E>

Apply the given folder folder to self; binders is the number of binders that are in scope when beginning the folder. Typically binders starts as 0, but is adjusted when we encounter Binders<T> in the IR or other similar constructs.
§

fn fold_with( self, folder: &mut dyn TypeFolder<I, Error = Infallible>, outer_binder: DebruijnIndex, ) -> Self

A convenient alternative to try_fold_with for use with infallible folders. Do not override this method, to ensure coherence with try_fold_with.
§

impl<I> TypeSuperFoldable<I> for Lifetime<I>
where I: Interner,

§

fn try_super_fold_with<E>( self, folder: &mut dyn FallibleTypeFolder<I, Error = E>, outer_binder: DebruijnIndex, ) -> Result<Lifetime<I>, E>

Recursively folds the value.
§

fn super_fold_with( self, folder: &mut dyn TypeFolder<I, Error = Infallible>, outer_binder: DebruijnIndex, ) -> Self

A convenient alternative to try_super_fold_with for use with infallible folders. Do not override this method, to ensure coherence with try_super_fold_with.
§

impl<I> TypeSuperVisitable<I> for Lifetime<I>
where I: Interner,

§

fn super_visit_with<B>( &self, visitor: &mut dyn TypeVisitor<I, BreakTy = B>, outer_binder: DebruijnIndex, ) -> ControlFlow<B>

Recursively visits the type contents.
§

impl<I> TypeVisitable<I> for Lifetime<I>
where I: Interner,

§

fn visit_with<B>( &self, visitor: &mut dyn TypeVisitor<I, BreakTy = B>, outer_binder: DebruijnIndex, ) -> ControlFlow<B>

Apply the given visitor visitor to self; binders is the number of binders that are in scope when beginning the visitor. Typically binders starts as 0, but is adjusted when we encounter Binders<T> in the IR or other similar constructs.
§

impl<I> Zip<I> for Lifetime<I>
where I: Interner,

§

fn zip_with<Z>( zipper: &mut Z, variance: Variance, a: &Lifetime<I>, b: &Lifetime<I>, ) -> Result<(), NoSolution>
where Z: Zipper<I>,

Uses the zipper to walk through two values, ensuring that they match.
§

impl<I> Copy for Lifetime<I>
where I: Copy + Interner, <I as Interner>::InternedLifetime: Copy,

§

impl<I> Eq for Lifetime<I>
where I: Eq + Interner, <I as Interner>::InternedLifetime: Eq,

§

impl<I> StructuralPartialEq for Lifetime<I>
where I: Interner,