pub struct Binder<'db, T: BoundTerm<'db>> {
pub variables: Vec<SymVariable<'db>>,
pub bound_value: T,
}Expand description
Indicates a binder for generic variables
Fields§
§variables: Vec<SymVariable<'db>>§bound_value: TImplementations§
Source§impl<'db, T: BoundTerm<'db>> Binder<'db, T>
impl<'db, T: BoundTerm<'db>> Binder<'db, T>
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn kind(&self, db: &'db dyn Db, index: usize) -> SymGenericKind
Sourcepub fn open(
&self,
db: &'db dyn Db,
func: impl FnMut(usize) -> T::GenericTerm,
) -> T::Outputwhere
T: Subst<'db>,
pub fn open(
&self,
db: &'db dyn Db,
func: impl FnMut(usize) -> T::GenericTerm,
) -> T::Outputwhere
T: Subst<'db>,
Generic way to “open” a binder, giving a function that computes the replacement
value for each bound variable. You may preference Self::substitute for the
most common cases.
§Parameters
db, the databasefunc, compute the replacement for bound variable at the given index
Sourcepub fn substitute(
&self,
db: &'db dyn Db,
substitution: &[impl Into<T::GenericTerm> + Copy],
) -> T::Output
pub fn substitute( &self, db: &'db dyn Db, substitution: &[impl Into<T::GenericTerm> + Copy], ) -> T::Output
Open the binder by replacing each variable with the corresponding term from substitution.
§Panics
If substitution does not have the correct length or there is a kind-mismatch.
Sourcepub fn map<U>(self, _db: &'db dyn Db, op: impl FnOnce(T) -> U) -> Binder<'db, U>where
U: BoundTerm<'db>,
pub fn map<U>(self, _db: &'db dyn Db, op: impl FnOnce(T) -> U) -> Binder<'db, U>where
U: BoundTerm<'db>,
Maps the bound contents to something else
using the contents of argument term arg.
arg will automatically have any bound variables
shifted by 1 to account for having been inserted
into a new binder.
If no arg is needed just supply ().
NB. The argument is a fn to prevent accidentally leaking context.
Sourcepub fn map_ref<U>(
&self,
_db: &'db dyn Db,
op: impl FnOnce(&T) -> U,
) -> Binder<'db, U>where
U: BoundTerm<'db>,
pub fn map_ref<U>(
&self,
_db: &'db dyn Db,
op: impl FnOnce(&T) -> U,
) -> Binder<'db, U>where
U: BoundTerm<'db>,
Maps the bound contents to something else
using the contents of argument term arg.
arg will automatically have any bound variables
shifted by 1 to account for having been inserted
into a new binder.
If no arg is needed just supply ().
NB. The argument is a fn to prevent accidentally leaking context.
Trait Implementations§
Source§impl<'db, T> BoundTerm<'db> for Binder<'db, T>where
T: BoundTerm<'db>,
impl<'db, T> BoundTerm<'db> for Binder<'db, T>where
T: BoundTerm<'db>,
const BINDER_LEVELS: usize
type BoundTerm = T
type LeafTerm = <T as BoundTerm<'db>>::LeafTerm
fn bind( db: &'db dyn Db, symbols_to_bind: &mut dyn Iterator<Item = Vec<SymVariable<'db>>>, leaf_value: T::LeafTerm, ) -> Self
fn as_binder(&self) -> Result<&Binder<'db, T>, &Self::LeafTerm>
Source§impl<'db, T: Ord + BoundTerm<'db>> Ord for Binder<'db, T>
impl<'db, T: Ord + BoundTerm<'db>> Ord for Binder<'db, T>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<'db, T: PartialOrd + BoundTerm<'db>> PartialOrd for Binder<'db, T>
impl<'db, T: PartialOrd + BoundTerm<'db>> PartialOrd for Binder<'db, T>
Source§impl<'db, T: BoundTerm<'db>> Subst<'db> for Binder<'db, T>
impl<'db, T: BoundTerm<'db>> Subst<'db> for Binder<'db, T>
Source§type GenericTerm = <T as Subst<'db>>::GenericTerm
type GenericTerm = <T as Subst<'db>>::GenericTerm
Source§fn subst_vars(
&self,
db: &'db dyn Db,
map: &Map<SymVariable<'db>, Self::GenericTerm>,
) -> Self::Output
fn subst_vars( &self, db: &'db dyn Db, map: &Map<SymVariable<'db>, Self::GenericTerm>, ) -> Self::Output
self where universal free variables
have been replaced by the corresponding entry in terms.
If a variable is not present in terms it is not substituted.Source§fn subst_var(
&self,
db: &'db dyn Db,
var: SymVariable<'db>,
term: Self::GenericTerm,
) -> Self::Output
fn subst_var( &self, db: &'db dyn Db, var: SymVariable<'db>, term: Self::GenericTerm, ) -> Self::Output
var with term.Source§fn resolve_infer_var(
&self,
db: &'db dyn Db,
bound_vars: &mut Vec<SymVariable<'db>>,
op: impl FnMut(InferVarIndex) -> Option<Self::GenericTerm>,
) -> Self::Output
fn resolve_infer_var( &self, db: &'db dyn Db, bound_vars: &mut Vec<SymVariable<'db>>, op: impl FnMut(InferVarIndex) -> Option<Self::GenericTerm>, ) -> Self::Output
op;
if op returns None, the inference variable is left unchanged.Source§impl<'db, T: BoundTerm<'db>> SubstWith<'db, <T as Subst<'db>>::GenericTerm> for Binder<'db, T>
impl<'db, T: BoundTerm<'db>> SubstWith<'db, <T as Subst<'db>>::GenericTerm> for Binder<'db, T>
Source§fn subst_with<'subst>(
&'subst self,
db: &'db dyn Db,
bound_vars: &mut Vec<SymVariable<'db>>,
subst_fns: &mut SubstitutionFns<'_, 'db, T::GenericTerm>,
) -> Self::Output
fn subst_with<'subst>( &'subst self, db: &'db dyn Db, bound_vars: &mut Vec<SymVariable<'db>>, subst_fns: &mut SubstitutionFns<'_, 'db, T::GenericTerm>, ) -> Self::Output
impl<'db, T: Eq + BoundTerm<'db>> Eq for Binder<'db, T>
impl<'db, T: BoundTerm<'db>> StructuralPartialEq for Binder<'db, T>
Auto Trait Implementations§
impl<'db, T> Freeze for Binder<'db, T>where
T: Freeze,
impl<'db, T> !RefUnwindSafe for Binder<'db, T>
impl<'db, T> Send for Binder<'db, T>where
T: Send,
impl<'db, T> Sync for Binder<'db, T>where
T: Sync,
impl<'db, T> Unpin for Binder<'db, T>where
T: Unpin,
impl<'db, T> UnsafeUnpin for Binder<'db, T>where
T: UnsafeUnpin,
impl<'db, T> !UnwindSafe for Binder<'db, T>
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,
§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<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<T> HashEqLike<T> for T
impl<T> HashEqLike<T> for T
§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