Macro canrun::goals::all

source ·
macro_rules! all {
    ($($item:expr),* $(,)?) => { ... };
}
Expand description

Create a goal that only succeeds if all sub-goals succeed.

This is essentially an “AND” operation on a vector of goals. The resulting state will be the result of the combining all of the sub-goals.

If the any goal fails, the rest of the goals will not be attempted.

Example

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

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