Skip to content

Loosen Fn bounds to FnMut #886

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ where
///
/// If `i` becomes exhausted before `j` becomes exhausted, the number of elements in `i` along with
/// the remaining `j` elements will be returned as `Diff::Longer`.
pub fn diff_with<I, J, F>(i: I, j: J, is_equal: F) -> Option<Diff<I::IntoIter, J::IntoIter>>
pub fn diff_with<I, J, F>(i: I, j: J, mut is_equal: F) -> Option<Diff<I::IntoIter, J::IntoIter>>
where
I: IntoIterator,
J: IntoIterator,
F: Fn(&I::Item, &J::Item) -> bool,
F: FnMut(&I::Item, &J::Item) -> bool,
{
let mut i = i.into_iter();
let mut j = j.into_iter();
Expand Down
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