Struct chalk_solve::goal_builder::GoalBuilder
source · pub struct GoalBuilder<'i, I: Interner> {
db: &'i dyn RustIrDatabase<I>,
}
Fields§
§db: &'i dyn RustIrDatabase<I>
Implementations§
source§impl<'i, I: Interner> GoalBuilder<'i, I>
impl<'i, I: Interner> GoalBuilder<'i, I>
pub fn new(db: &'i dyn RustIrDatabase<I>) -> Self
sourcepub fn db(&self) -> &'i dyn RustIrDatabase<I>
pub fn db(&self) -> &'i dyn RustIrDatabase<I>
Returns the database within the goal builder.
sourcepub fn all<GS, G>(&mut self, goals: GS) -> Goal<I>
pub fn all<GS, G>(&mut self, goals: GS) -> Goal<I>
Creates a goal that ensures all of the goals from the goals
iterator are met (e.g., goals[0] && ... && goals[N]
).
sourcepub fn implies<CS, C, G>(
&mut self,
clauses: CS,
goal: impl FnOnce(&mut Self) -> G,
) -> Goal<I>
pub fn implies<CS, C, G>( &mut self, clauses: CS, goal: impl FnOnce(&mut Self) -> G, ) -> Goal<I>
Creates a goal clauses => goal
. The clauses are given as an iterator
and the goal is returned via the contained closure.
sourcepub fn forall<G, B, P>(
&mut self,
binders: &Binders<B>,
passthru: P,
body: fn(_: &mut Self, _: Substitution<I>, _: &B, _: P) -> G,
) -> Goal<I>
pub fn forall<G, B, P>( &mut self, binders: &Binders<B>, passthru: P, body: fn(_: &mut Self, _: Substitution<I>, _: &B, _: P) -> G, ) -> Goal<I>
Given a bound value binders
like <P0..Pn> V
,
creates a goal forall<Q0..Qn> { G }
where
the goal G
is created by invoking a helper
function body
.
§Parameters to body
body
will be invoked with:
- the goal builder
self
- the substitution
Q0..Qn
- the bound value
[P0..Pn => Q0..Qn] V
instantiated with the substitution - the value
passthru
, appropriately shifted so that any debruijn indices within account for the new binder
§Why is body
a function and not a closure?
This is to ensure that body
doesn’t accidentally reference
values from the environment whose debruijn indices do not
account for the new binder being created.
sourcepub fn exists<G, B, P>(
&mut self,
binders: &Binders<B>,
passthru: P,
body: fn(_: &mut Self, _: Substitution<I>, _: &B, _: P) -> G,
) -> Goal<I>
pub fn exists<G, B, P>( &mut self, binders: &Binders<B>, passthru: P, body: fn(_: &mut Self, _: Substitution<I>, _: &B, _: P) -> G, ) -> Goal<I>
Like GoalBuilder::forall
, but for a exists<Q0..Qn> { G }
goal.
sourcefn quantified<G, B, P>(
&mut self,
quantifier_kind: QuantifierKind,
binders: &Binders<B>,
passthru: P,
body: fn(_: &mut Self, _: Substitution<I>, _: &B, _: P) -> G,
) -> Goal<I>
fn quantified<G, B, P>( &mut self, quantifier_kind: QuantifierKind, binders: &Binders<B>, passthru: P, body: fn(_: &mut Self, _: Substitution<I>, _: &B, _: P) -> G, ) -> Goal<I>
A combined helper functon for the various methods
to create forall
and exists
goals. See:
for details.
Auto Trait Implementations§
impl<'i, I> Freeze for GoalBuilder<'i, I>
impl<'i, I> !RefUnwindSafe for GoalBuilder<'i, I>
impl<'i, I> !Send for GoalBuilder<'i, I>
impl<'i, I> !Sync for GoalBuilder<'i, I>
impl<'i, I> Unpin for GoalBuilder<'i, I>
impl<'i, I> !UnwindSafe for GoalBuilder<'i, I>
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> Cast for T
impl<T> Cast for T
source§fn cast<U>(self, interner: <U as HasInterner>::Interner) -> Uwhere
Self: CastTo<U>,
U: HasInterner,
fn cast<U>(self, interner: <U as HasInterner>::Interner) -> Uwhere
Self: CastTo<U>,
U: HasInterner,
U
using CastTo
.