Function canrun::collections::lvec::subset
source · pub fn subset<T, SV, CV>(subset: SV, collection: CV) -> Subset<T>where
T: Unify,
SV: Into<Value<LVec<T>>>,
LVec<T>: Unify,
CV: Into<Value<LVec<T>>>,
Expand description
Assert that LVec
a
is a subset of LVec
b
.
This means that all of the items in a
unify with a contiguous run of items in b
.
This goal will fork the state for each match found.
Examples:
use canrun::{LVar, all, unify, lvec, Query};
let needle = LVar::new();
let haystack = LVar::new();
let goal = all![
unify(&needle, lvec![1]),
unify(&haystack, lvec![1, 2, 3]),
lvec::subset(&needle, haystack),
];
let results: Vec<_> = goal.query(needle).collect();
assert_eq!(results, vec![vec![1]]);