Function canrun::goals::project_1[][src]

pub fn project_1<'a, A, AV, D, F>(a: AV, func: F) -> Goal<'a, D> where
    A: Debug + 'a,
    AV: IntoVal<A>,
    D: DomainType<'a, A>,
    F: Fn(&A) -> Goal<'a, D> + 'a, 
Expand description

Create a projection goal that allows creating a new goal based on the resolved value.

use canrun::{Goal, both, unify, var, project_1};
use canrun::example::I32;

let x = var();
let goal: Goal<I32> = both(unify(1, x), project_1(x, |x| if *x < 2 { Goal::succeed() } else { Goal::fail() }));
let result: Vec<_> = goal.query(x).collect();
assert_eq!(result, vec![1])