Skip to content

Commit

Permalink
fn new_map_for_grouping as free function
Browse files Browse the repository at this point in the history
  • Loading branch information
phimuemue committed Feb 12, 2024
1 parent 3de4e6c commit 943a336
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
10 changes: 4 additions & 6 deletions src/grouping_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,10 @@ impl<V, K, F: FnMut(&V) -> K> MapSpecialCaseFn<V> for GroupingMapFn<F> {
}
}

impl<K, I: Iterator, F: FnMut(&I::Item) -> K> MapForGrouping<I, F> {
pub(crate) fn new(iter: I, key_mapper: F) -> Self {
MapSpecialCase {
iter,
f: GroupingMapFn(key_mapper),
}
pub(crate) fn new_map_for_grouping<K, I: Iterator, F: FnMut(&I::Item) ->K>(iter: I, key_mapper: F) -> MapForGrouping<I, F> {
MapSpecialCase {
iter,
f: GroupingMapFn(key_mapper),
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3194,7 +3194,7 @@ pub trait Itertools: Iterator {
K: Hash + Eq,
F: FnMut(&V) -> K,
{
grouping_map::new(grouping_map::MapForGrouping::new(self, key_mapper))
grouping_map::new(grouping_map::new_map_for_grouping(self, key_mapper))
}

/// Return all minimum elements of an iterator.
Expand Down

0 comments on commit 943a336

Please sign in to comment.