Type Alias chalk_solve::rust_ir::QuantifiedInlineBound
source · pub type QuantifiedInlineBound<I: Interner> = Binders<InlineBound<I>>;
Aliased Type§
struct QuantifiedInlineBound<I: Interner> {
pub binders: VariableKinds<I>,
/* private fields */
}
Fields§
§binders: VariableKinds<I>
The binders that quantify over the value.
Implementations
source§impl<T> Binders<T>where
T: HasInterner,
impl<T> Binders<T>where
T: HasInterner,
sourcepub fn new(
binders: VariableKinds<<T as HasInterner>::Interner>,
value: T,
) -> Binders<T>
pub fn new( binders: VariableKinds<<T as HasInterner>::Interner>, value: T, ) -> Binders<T>
Create new binders.
sourcepub fn empty(interner: <T as HasInterner>::Interner, value: T) -> Binders<T>
pub fn empty(interner: <T as HasInterner>::Interner, value: T) -> Binders<T>
Wraps the given value in a binder without variables, i.e. for<> (value)
. Since our deBruijn indices count binders, not variables, this
is sometimes useful.
sourcepub fn skip_binders(&self) -> &T
pub fn skip_binders(&self) -> &T
Skips the binder and returns the “bound” value. This is a
risky thing to do because it’s easy to get confused about
De Bruijn indices and the like. skip_binder
is only valid
when you are either extracting data that has nothing to
do with bound vars, or you are being very careful about
your depth accounting.
Some examples where skip_binder
is reasonable:
- extracting the
TraitId
from a TraitRef; - checking if there are any fields in a StructDatum
sourcepub fn into_value_and_skipped_binders(
self,
) -> (T, VariableKinds<<T as HasInterner>::Interner>)
pub fn into_value_and_skipped_binders( self, ) -> (T, VariableKinds<<T as HasInterner>::Interner>)
Skips the binder and returns the “bound” value as well as the skipped free variables. This
is just as risky as skip_binders
.
sourcepub fn as_ref(&self) -> Binders<&T>
pub fn as_ref(&self) -> Binders<&T>
Converts &Binders<T>
to Binders<&T>
. Produces new Binders
with cloned quantifiers containing a reference to the original
value, leaving the original in place.
sourcepub fn filter_map<U, OP>(self, op: OP) -> Option<Binders<U>>
pub fn filter_map<U, OP>(self, op: OP) -> Option<Binders<U>>
Transforms the inner value according to the given function; returns
None
if the function returns None
.
sourcepub fn map_ref<'a, U, OP>(&'a self, op: OP) -> Binders<U>
pub fn map_ref<'a, U, OP>(&'a self, op: OP) -> Binders<U>
Maps a function taking Binders<&T>
over &Binders<T>
.
sourcepub fn identity_substitution(
&self,
interner: <T as HasInterner>::Interner,
) -> Substitution<<T as HasInterner>::Interner>
pub fn identity_substitution( &self, interner: <T as HasInterner>::Interner, ) -> Substitution<<T as HasInterner>::Interner>
Creates a Substitution
containing bound vars such that applying this
substitution will not change the value, i.e. ^0.0, ^0.1, ^0.2
and so
on.
sourcepub fn with_fresh_type_var(
interner: <T as HasInterner>::Interner,
op: impl FnOnce(Ty<<T as HasInterner>::Interner>) -> T,
) -> Binders<T>
pub fn with_fresh_type_var( interner: <T as HasInterner>::Interner, op: impl FnOnce(Ty<<T as HasInterner>::Interner>) -> T, ) -> Binders<T>
Creates a fresh binders that contains a single type variable. The result of the closure will be embedded in this binder. Note that you should be careful with what you return from the closure to account for the binder that will be added.
XXX FIXME – this is potentially a pretty footgun-y function.
sourcepub fn len(&self, interner: <T as HasInterner>::Interner) -> usize
pub fn len(&self, interner: <T as HasInterner>::Interner) -> usize
Returns the number of binders.
source§impl<T, I> Binders<T>
impl<T, I> Binders<T>
sourcepub fn substitute(
self,
interner: I,
parameters: &(impl AsParameters<I> + ?Sized),
) -> T
pub fn substitute( self, interner: I, parameters: &(impl AsParameters<I> + ?Sized), ) -> T
Substitute parameters
for the variables introduced by these
binders. So if the binders represent (e.g.) <X, Y> { T }
and
parameters is the slice [A, B]
, then returns [X => A, Y => B] T
.
Trait Implementations§
source§impl<I: Interner> IntoWhereClauses<I> for QuantifiedInlineBound<I>
impl<I: Interner> IntoWhereClauses<I> for QuantifiedInlineBound<I>
type Output = Binders<WhereClause<I>>
fn into_where_clauses( &self, interner: I, self_ty: Ty<I>, ) -> Vec<QuantifiedWhereClause<I>>
source§impl<I: Interner> RenderAsRust<I> for QuantifiedInlineBound<I>
impl<I: Interner> RenderAsRust<I> for QuantifiedInlineBound<I>
fn fmt(&self, s: &InternalWriterState<'_, I>, f: &mut Formatter<'_>) -> Result
fn display<'a>(
&'a self,
s: &'a InternalWriterState<'a, I>,
) -> DisplayRenderAsRust<'a, I, Self>where
Self: Sized,
source§impl<I, T> CastTo<ProgramClause<I>> for Binders<T>
impl<I, T> CastTo<ProgramClause<I>> for Binders<T>
source§fn cast_to(self, interner: I) -> ProgramClause<I>
fn cast_to(self, interner: I) -> ProgramClause<I>
T
.source§impl<T> HasInterner for Binders<T>where
T: HasInterner,
impl<T> HasInterner for Binders<T>where
T: HasInterner,
§type Interner = <T as HasInterner>::Interner
type Interner = <T as HasInterner>::Interner
source§impl<V, U> IntoIterator for Binders<V>where
V: HasInterner + IntoIterator<Item = U>,
U: HasInterner<Interner = <V as HasInterner>::Interner>,
impl<V, U> IntoIterator for Binders<V>where
V: HasInterner + IntoIterator<Item = U>,
U: HasInterner<Interner = <V as HasInterner>::Interner>,
Allows iterating over a Binders<Vec
source§impl<T> PartialEq for Binders<T>
impl<T> PartialEq for Binders<T>
source§impl<T, I> TypeFoldable<I> for Binders<T>
impl<T, I> TypeFoldable<I> for Binders<T>
source§fn try_fold_with<E>(
self,
folder: &mut dyn FallibleTypeFolder<I, Error = E>,
outer_binder: DebruijnIndex,
) -> Result<Binders<T>, E>
fn try_fold_with<E>( self, folder: &mut dyn FallibleTypeFolder<I, Error = E>, outer_binder: DebruijnIndex, ) -> Result<Binders<T>, E>
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.source§fn fold_with(
self,
folder: &mut dyn TypeFolder<I, Error = Infallible>,
outer_binder: DebruijnIndex,
) -> Self
fn fold_with( self, folder: &mut dyn TypeFolder<I, Error = Infallible>, outer_binder: DebruijnIndex, ) -> Self
try_fold_with
for use with infallible
folders. Do not override this method, to ensure coherence with
try_fold_with
.source§impl<T, I> TypeVisitable<I> for Binders<T>
impl<T, I> TypeVisitable<I> for Binders<T>
source§fn visit_with<B>(
&self,
visitor: &mut dyn TypeVisitor<I, BreakTy = B>,
outer_binder: DebruijnIndex,
) -> ControlFlow<B>
fn visit_with<B>( &self, visitor: &mut dyn TypeVisitor<I, BreakTy = B>, outer_binder: DebruijnIndex, ) -> ControlFlow<B>
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.