[−][src]Struct chalk_ir::Binders
Indicates that the value
is universally quantified over N
parameters of the given kinds, where N == self.binders.len()
. A
variable with depth i < N
refers to the value at
self.binders[i]
. Variables with depth >= N
are free.
(IOW, we use deBruijn indices, where binders are introduced in reverse order
of self.binders
.)
Fields
binders: VariableKinds<T::Interner>
The binders that quantify over the value.
Implementations
impl<I: Interner> Binders<WhereClause<I>>
[src]
pub fn into_well_formed_goal(self, interner: &I) -> Binders<DomainGoal<I>>
[src]
As with WhereClause::into_well_formed_goal
, but for a
quantified where clause. For example, forall<T> { Implemented(T: Trait)}
would map to forall<T> { WellFormed(T: Trait) }
.
pub fn into_from_env_goal(self, interner: &I) -> Binders<DomainGoal<I>>
[src]
As with WhereClause::into_from_env_goal
, but mapped over any
binders. For example, forall<T> { Implemented(T: Trait)}
would map to forall<T> { FromEnv(T: Trait) }
.
pub fn trait_id(&self) -> Option<TraitId<I>>
[src]
If the underlying where clause is a TraitRef
, returns its trait id.
impl<T: HasInterner> Binders<T>
[src]
pub fn new(binders: VariableKinds<T::Interner>, value: T) -> Self
[src]
Create new binders.
pub fn empty(interner: &T::Interner, value: T) -> Self
[src]
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.
pub fn skip_binders(&self) -> &T
[src]
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
pub fn as_ref(&self) -> Binders<&T>
[src]
Converts &Binders<T>
to Binders<&T>
. Produces new Binders
with cloned quantifiers containing a reference to the original
value, leaving the original in place.
pub fn map<U, OP>(self, op: OP) -> Binders<U> where
OP: FnOnce(T) -> U,
U: HasInterner<Interner = T::Interner>,
[src]
OP: FnOnce(T) -> U,
U: HasInterner<Interner = T::Interner>,
Maps the binders by applying a function.
pub fn filter_map<U, OP>(self, op: OP) -> Option<Binders<U>> where
OP: FnOnce(T) -> Option<U>,
U: HasInterner<Interner = T::Interner>,
[src]
OP: FnOnce(T) -> Option<U>,
U: HasInterner<Interner = T::Interner>,
Transforms the inner value according to the given function; returns
None
if the function returns None
.
pub fn map_ref<'a, U, OP>(&'a self, op: OP) -> Binders<U> where
OP: FnOnce(&'a T) -> U,
U: HasInterner<Interner = T::Interner>,
[src]
OP: FnOnce(&'a T) -> U,
U: HasInterner<Interner = T::Interner>,
Maps a function taking Binders<&T>
over &Binders<T>
.
pub fn identity_substitution(
&self,
interner: &T::Interner
) -> Substitution<T::Interner>
[src]
&self,
interner: &T::Interner
) -> Substitution<T::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.
pub fn with_fresh_type_var(
interner: &T::Interner,
op: impl FnOnce(Ty<T::Interner>) -> T
) -> Binders<T>
[src]
interner: &T::Interner,
op: impl FnOnce(Ty<T::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.
pub fn len(&self, interner: &T::Interner) -> usize
[src]
Returns the number of binders.
impl<T, I> Binders<Binders<T>> where
T: Fold<I, I> + HasInterner<Interner = I>,
T::Result: HasInterner<Interner = I>,
I: Interner,
[src]
T: Fold<I, I> + HasInterner<Interner = I>,
T::Result: HasInterner<Interner = I>,
I: Interner,
pub fn fuse_binders(self, interner: &T::Interner) -> Binders<T::Result>
[src]
This turns two levels of binders (for<A> for<B>
) into one level (for<A, B>
).
impl<T, I> Binders<T> where
T: Fold<I, I> + HasInterner<Interner = I>,
I: Interner,
[src]
T: Fold<I, I> + HasInterner<Interner = I>,
I: Interner,
pub fn substitute(
&self,
interner: &I,
parameters: &impl AsParameters<I> + ?Sized
) -> T::Result
[src]
&self,
interner: &I,
parameters: &impl AsParameters<I> + ?Sized
) -> T::Result
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
impl<I: Interner> CastTo<Binders<WhereClause<I>>> for QuantifiedWhereClause<I>
[src]
fn cast_to(
self,
_interner: &<QuantifiedWhereClause<I> as HasInterner>::Interner
) -> QuantifiedWhereClause<I>
[src]
self,
_interner: &<QuantifiedWhereClause<I> as HasInterner>::Interner
) -> QuantifiedWhereClause<I>
impl<I: Interner, T: HasInterner<Interner = I> + CastTo<Goal<I>>> CastTo<Goal<I>> for Binders<T>
[src]
impl<I, T> CastTo<ProgramClause<I>> for Binders<T> where
I: Interner,
T: HasInterner<Interner = I> + CastTo<DomainGoal<I>>,
[src]
I: Interner,
T: HasInterner<Interner = I> + CastTo<DomainGoal<I>>,
fn cast_to(self, interner: &I) -> ProgramClause<I>
[src]
impl<T: Clone + HasInterner> Clone for Binders<T> where
T::Interner: Clone,
[src]
T::Interner: Clone,
impl<T: HasInterner + Copy> Copy for Binders<T> where
<T::Interner as Interner>::InternedVariableKinds: Copy,
[src]
<T::Interner as Interner>::InternedVariableKinds: Copy,
impl<T: HasInterner + Debug> Debug for Binders<T>
[src]
impl<T: Eq + HasInterner> Eq for Binders<T> where
T::Interner: Eq,
[src]
T::Interner: Eq,
impl<T, I: Interner, TI: TargetInterner<I>> Fold<I, TI> for Binders<T> where
T: HasInterner<Interner = I> + Fold<I, TI>,
<T as Fold<I, TI>>::Result: HasInterner<Interner = TI>,
I: Interner,
[src]
T: HasInterner<Interner = I> + Fold<I, TI>,
<T as Fold<I, TI>>::Result: HasInterner<Interner = TI>,
I: Interner,
type Result = Binders<T::Result>
The type of value that will be produced once folding is done.
Typically this is Self
, unless Self
contains borrowed
values, in which case owned values are produced (for example,
one can fold over a &T
value where T: Fold
, in which case
you get back a T
, not a &T
). Read more
fn fold_with<'i>(
&self,
folder: &mut dyn Folder<'i, I, TI>,
outer_binder: DebruijnIndex
) -> Fallible<Self::Result> where
I: 'i,
TI: 'i,
[src]
&self,
folder: &mut dyn Folder<'i, I, TI>,
outer_binder: DebruijnIndex
) -> Fallible<Self::Result> where
I: 'i,
TI: 'i,
impl<T: HasInterner> From<Binders<T>> for (VariableKinds<T::Interner>, T)
[src]
impl<T: HasInterner> HasInterner for Binders<T>
[src]
impl<T: Hash + HasInterner> Hash for Binders<T> where
T::Interner: Hash,
[src]
T::Interner: Hash,
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<V, U> IntoIterator for Binders<V> where
V: HasInterner + IntoIterator<Item = U>,
U: HasInterner<Interner = V::Interner>,
[src]
V: HasInterner + IntoIterator<Item = U>,
U: HasInterner<Interner = V::Interner>,
Allows iterating over a Binders<Vec
type Item = Binders<U>
The type of the elements being iterated over.
type IntoIter = BindersIntoIterator<V>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
impl<T: PartialEq + HasInterner> PartialEq<Binders<T>> for Binders<T> where
T::Interner: PartialEq,
[src]
T::Interner: PartialEq,
impl<T: HasInterner> StructuralEq for Binders<T>
[src]
impl<T: HasInterner> StructuralPartialEq for Binders<T>
[src]
impl<T, I: Interner> Visit<I> for Binders<T> where
T: HasInterner + Visit<I>,
[src]
T: HasInterner + Visit<I>,
fn visit_with<'i, R: VisitResult>(
&self,
visitor: &mut dyn Visitor<'i, I, Result = R>,
outer_binder: DebruijnIndex
) -> R where
I: 'i,
[src]
&self,
visitor: &mut dyn Visitor<'i, I, Result = R>,
outer_binder: DebruijnIndex
) -> R where
I: 'i,
impl<I: Interner, T: HasInterner<Interner = I> + Zip<I> + Fold<I, I, Result = T>> Zip<I> for Binders<T>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for Binders<T> where
T: RefUnwindSafe,
<<T as HasInterner>::Interner as Interner>::InternedVariableKinds: RefUnwindSafe,
T: RefUnwindSafe,
<<T as HasInterner>::Interner as Interner>::InternedVariableKinds: RefUnwindSafe,
impl<T> Send for Binders<T> where
T: Send,
<<T as HasInterner>::Interner as Interner>::InternedVariableKinds: Send,
T: Send,
<<T as HasInterner>::Interner as Interner>::InternedVariableKinds: Send,
impl<T> Sync for Binders<T> where
T: Sync,
<<T as HasInterner>::Interner as Interner>::InternedVariableKinds: Sync,
T: Sync,
<<T as HasInterner>::Interner as Interner>::InternedVariableKinds: Sync,
impl<T> Unpin for Binders<T> where
T: Unpin,
<<T as HasInterner>::Interner as Interner>::InternedVariableKinds: Unpin,
T: Unpin,
<<T as HasInterner>::Interner as Interner>::InternedVariableKinds: Unpin,
impl<T> UnwindSafe for Binders<T> where
T: UnwindSafe,
<<T as HasInterner>::Interner as Interner>::InternedVariableKinds: UnwindSafe,
T: UnwindSafe,
<<T as HasInterner>::Interner as Interner>::InternedVariableKinds: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Cast for T
[src]
fn cast<U>(self, interner: &U::Interner) -> U where
Self: CastTo<U>,
U: HasInterner,
[src]
Self: CastTo<U>,
U: HasInterner,
impl<T, I> CastTo<Goal<I>> for T where
I: Interner,
T: CastTo<DomainGoal<I>>,
[src]
I: Interner,
T: CastTo<DomainGoal<I>>,
impl<T, I> CastTo<ProgramClause<I>> for T where
I: Interner,
T: CastTo<DomainGoal<I>>,
[src]
I: Interner,
T: CastTo<DomainGoal<I>>,
fn cast_to(Self, &I) -> ProgramClause<I>
[src]
impl<T, I> CouldMatch<T> for T where
I: Interner,
T: Zip<I> + HasInterner<Interner = I> + ?Sized,
[src]
I: Interner,
T: Zip<I> + HasInterner<Interner = I> + ?Sized,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<I> IntoIterator for I where
I: Iterator,
[src]
I: Iterator,
type Item = <I as Iterator>::Item
The type of the elements being iterated over.
type IntoIter = I
Which kind of iterator are we turning this into?
fn into_iter(self) -> I
[src]
impl<T, I> Shift<I> for T where
I: Interner,
T: Fold<I, I>,
[src]
I: Interner,
T: Fold<I, I>,
fn shifted_in(&Self, &I) -> <T as Fold<I, I>>::Result
[src]
fn shifted_in_from(&Self, &I, DebruijnIndex) -> <T as Fold<I, I>>::Result
[src]
fn shifted_out_to(
&Self,
&I,
DebruijnIndex
) -> Result<<T as Fold<I, I>>::Result, NoSolution>
[src]
&Self,
&I,
DebruijnIndex
) -> Result<<T as Fold<I, I>>::Result, NoSolution>
fn shifted_out(&Self, &I) -> Result<<T as Fold<I, I>>::Result, NoSolution>
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T, I> VisitExt<I> for T where
I: Interner,
T: Visit<I>,
[src]
I: Interner,
T: Visit<I>,