diff --git a/src/group_map.rs b/src/group_map.rs index 8891f95ac..3dcee83af 100644 --- a/src/group_map.rs +++ b/src/group_map.rs @@ -22,10 +22,11 @@ where lookup } -pub fn into_group_map_by(iter: I, f: impl Fn(&V) -> K) -> HashMap> +pub fn into_group_map_by(iter: I, mut f: F) -> HashMap> where I: Iterator, K: Hash + Eq, + F: FnMut(&V) -> K, { into_group_map(iter.map(|v| (f(&v), v))) } diff --git a/src/lib.rs b/src/lib.rs index 64f2b5ac4..7171b1dc0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3257,7 +3257,7 @@ pub trait Itertools: Iterator { where Self: Iterator + Sized, K: Hash + Eq, - F: Fn(&V) -> K, + F: FnMut(&V) -> K, { group_map::into_group_map_by(self, f) }