fn compare_loop_all()

in guard/src/rules/evaluate.rs [72:103]


fn compare_loop_all<F>(lhs: &Vec<&PathAwareValue>, rhs: &Vec<&PathAwareValue>, compare: F, any_one_rhs: bool)
    -> Result<(bool, Vec<(bool, Option<PathAwareValue>, Option<PathAwareValue>)>)>
    where F: Fn(&PathAwareValue, &PathAwareValue) -> Result<bool>
{
    let mut lhs_cmp = true;
    let mut results = Vec::with_capacity(lhs.len());
    'lhs: for lhs_value in lhs {
        let mut acc = Vec::with_capacity(lhs.len());
        for rhs_value in rhs {
            let check = compare(*lhs_value, *rhs_value)?;
            if check {
                if any_one_rhs {
                    acc.clear();
                    results.push((true, None, None));
                    continue 'lhs
                }
                acc.push((true, None, None));
            }
            else {
                acc.push((false, Some((*lhs_value).clone()), Some((*rhs_value).clone())));
                if !any_one_rhs {
                    lhs_cmp = false;
                }
            }
        }
        if any_one_rhs {
            lhs_cmp = false;
        }
        results.extend(acc)
    }
    Ok((lhs_cmp, results))
}