Function canrun::goals::project::assert_2

source ·
pub fn assert_2<A, IA, B, IB, F>(a: IA, b: IB, func: F) -> Assert2<A, B>where
    A: Unify,
    IA: Into<Value<A>>,
    B: Unify,
    IB: Into<Value<B>>,
    F: Fn(&A, &B) -> bool + 'static,
Expand description

Create a projection goal that succeeds if the resolved values pass an assertion test.

use canrun::{LVar, Query};
use canrun::goals::{assert_2, all, unify};

let (x, y) = (LVar::new(), LVar::new());
let goal = all![
    unify(1, x),
    unify(2, y),
    assert_2(x, y, |x, y| x < y),
];
let result: Vec<_> = goal.query((x, y)).collect();
assert_eq!(result, vec![(1, 2)])