Skip to content

Commit

Permalink
into_group_map_by with FnMut
Browse files Browse the repository at this point in the history
  • Loading branch information
Philippe-Cholet committed Feb 27, 2024
1 parent de00c7a commit 3918da2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/group_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ where
lookup
}

pub fn into_group_map_by<I, K, V>(iter: I, f: impl Fn(&V) -> K) -> HashMap<K, Vec<V>>
pub fn into_group_map_by<I, K, V, F>(iter: I, mut f: F) -> HashMap<K, Vec<V>>
where
I: Iterator<Item = V>,
K: Hash + Eq,
F: FnMut(&V) -> K,
{
into_group_map(iter.map(|v| (f(&v), v)))
}
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3257,7 +3257,7 @@ pub trait Itertools: Iterator {
where
Self: Iterator<Item = V> + Sized,
K: Hash + Eq,
F: Fn(&V) -> K,
F: FnMut(&V) -> K,
{
group_map::into_group_map_by(self, f)
}
Expand Down

0 comments on commit 3918da2

Please sign in to comment.