diff --git a/lib/src/atom/matcher.rs b/lib/src/atom/matcher.rs index ff036e047..86fbd417d 100644 --- a/lib/src/atom/matcher.rs +++ b/lib/src/atom/matcher.rs @@ -1192,12 +1192,12 @@ pub fn atoms_are_equivalent(left: &Atom, right: &Atom) -> bool { use std::collections::hash_map::Entry; -fn atoms_are_equivalent_with_bindings<'a, 'b: 'a>(left: &'b Atom, right: &'b Atom, - left_vars: &'a mut HashMap<&'b VariableAtom, &'b VariableAtom>, - right_vars: &'a mut HashMap<&'b VariableAtom, &'b VariableAtom>) -> bool { +fn atoms_are_equivalent_with_bindings<'a>(left: &'a Atom, right: &'a Atom, + left_vars: &mut HashMap<&'a VariableAtom, &'a VariableAtom>, + right_vars: &mut HashMap<&'a VariableAtom, &'a VariableAtom>) -> bool { - fn can_be_renamed<'a, 'b: 'a>(map: &'a mut HashMap<&'b VariableAtom, &'b VariableAtom>, - var: &'b VariableAtom, atom: &'b VariableAtom) -> bool { + fn can_be_renamed<'a>(map: &mut HashMap<&'a VariableAtom, &'a VariableAtom>, + var: &'a VariableAtom, atom: &'a VariableAtom) -> bool { match map.entry(var) { Entry::Occupied(entry) => *entry.get() == atom, Entry::Vacant(entry) => { diff --git a/lib/src/common/assert.rs b/lib/src/common/assert.rs index 13867c5a5..ade46fa42 100644 --- a/lib/src/common/assert.rs +++ b/lib/src/common/assert.rs @@ -3,18 +3,18 @@ use super::collections::{ListMap, Equality, DefaultEquality}; use std::fmt::{Debug, Display, Formatter}; use itertools::Itertools; -pub fn compare_vec_no_order<'a, T, A, B, E>(actual: A, expected: B, _cmp: E) -> VecDiff<'a, T, E> +pub fn compare_vec_no_order(actual: A, expected: B, _cmp: E) -> VecDiff where - A: Iterator, - B: Iterator, - E: Equality<&'a T>, + A: Iterator, + B: Iterator, + E: Equality, { - let mut diff: ListMap<&T, Count, E> = ListMap::new(); + let mut diff: ListMap = ListMap::new(); for i in actual { - diff.entry(&i).or_default().actual += 1; + diff.entry(i).or_default().actual += 1; } for i in expected { - diff.entry(&i).or_default().expected += 1; + diff.entry(i).or_default().expected += 1; } diff = diff.into_iter().filter(|(_v, c)| c.actual != c.expected).collect(); VecDiff{ diff } @@ -26,8 +26,8 @@ struct Count { expected: usize, } -pub struct VecDiff<'a, T, E: Equality<&'a T>> { - diff: ListMap<&'a T, Count, E>, +pub struct VecDiff> { + diff: ListMap, } struct FormatAsDebug(T); @@ -44,7 +44,7 @@ impl Display for FormatAsDisplay { } } -impl<'a, T, E: Equality<&'a T>> VecDiff<'a, T, E> { +impl> VecDiff { pub fn has_diff(&self) -> bool { !self.diff.is_empty() } @@ -57,20 +57,20 @@ impl<'a, T, E: Equality<&'a T>> VecDiff<'a, T, E> { self.as_string(FormatAsDebug) } - fn as_string(&self, f: F) -> Option - where F: Fn(&'a T) -> I + fn as_string<'a, F, I: 'a + Display>(&'a self, f: F) -> Option + where F: Copy + Fn(&'a T) -> I { let mut diff = String::new(); if self.has_diff() { let mut missed = self.diff.iter() .filter(|(_v, c)| c.actual < c.expected) .flat_map(|(v, c)| std::iter::repeat_n(v, c.expected - c.actual)) - .map(|v| f(v)) + .map(f) .peekable(); let mut excessive = self.diff.iter() .filter(|(_v, c)| c.actual > c.expected) .flat_map(|(v, c)| std::iter::repeat_n(v, c.actual - c.expected)) - .map(|v| f(v)) + .map(f) .peekable(); if missed.peek().is_some() { diff.push_str(format!("Missed results: {}", missed.format(", ")).as_str());