Function canrun::goals::project::assert_1

source ·
pub fn assert_1<T, A, F>(a: A, func: F) -> Assert1<T>where
    T: Unify,
    A: Into<Value<T>>,
    F: Fn(&T) -> bool + 'static,
Expand description

Create a projection goal that succeeds if the resolved value passes an assertion test.

use canrun::{LVar, Query};
use canrun::goals::{assert_1, both, unify};

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