From 3918da235ede43a2e44f517b0bedd4711cb00109 Mon Sep 17 00:00:00 2001 From: Philippe-Cholet <44676486+Philippe-Cholet@users.noreply.github.com> Date: Tue, 27 Feb 2024 15:31:06 +0100 Subject: [PATCH] `into_group_map_by` with `FnMut` --- src/group_map.rs | 3 ++- src/lib.rs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) 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) }