diff --git a/src/expressions/mod.rs b/src/expressions/mod.rs index 35f912f..02c5db0 100644 --- a/src/expressions/mod.rs +++ b/src/expressions/mod.rs @@ -61,7 +61,7 @@ impl Expression { } pub fn n_ary_and(es: Vec>) -> Expression { - And(es.into_iter().map(|e| Box::new(e)).collect()) + And(es.into_iter().map(Box::new).collect()) } pub fn binary_or(e1: Expression, e2: Expression) -> Expression { @@ -69,19 +69,15 @@ impl Expression { } pub fn n_ary_or(es: Vec>) -> Expression { - Or(es.into_iter().map(|e| Box::new(e)).collect()) + Or(es.into_iter().map(Box::new).collect()) } pub fn evaluate(&self, literal_values: &HashMap) -> bool { match self { Literal(ref t) => *literal_values.get(t).unwrap_or(&false), Constant(ref value) => *value, - And(ref values) => values - .iter() - .fold(true, |acc, e| acc && e.evaluate(literal_values)), - Or(ref values) => values - .iter() - .fold(false, |acc, e| acc || e.evaluate(literal_values)), + And(ref values) => values.iter().all(|e| e.evaluate(literal_values)), + Or(ref values) => values.iter().any(|e| e.evaluate(literal_values)), Not(ref x) => !x.evaluate(literal_values), } }