rust-itertools / itertools

Extra iterator adaptors, iterator methods, free functions, and macros.
https://docs.rs/itertools/
Apache License 2.0
2.76k stars 309 forks source link

`Itertools::dedup_by[_key]` vs `Vec` #930

Open Philippe-Cholet opened 6 months ago

Philippe-Cholet commented 6 months ago

First, Itertools::dedup_by[_with_count] uses FnMut(&Self::Item, &Self::Item) -> bool while Vec::dedup_by uses FnMut(&mut T, &mut T) -> bool. It differs in mutability: & vs &mut. Not sure why yet.

Second, Vec::dedup_by_key exists but Itertools::dedup_by_key[_with_count] do not:

trait Itertools {
    fn dedup_by_key<F, K>(self, key: F) -> DedupByKey<Self, F>
    where
        Self: Sized,
        F: FnMut(&/*mut ??*/ Self::Item) -> K,
        K: PartialEq;

    fn dedup_by_key_with_count<F, K>(self, key: F) -> DedupByKeyWithCount<Self, F>
    where
        Self: Sized,
        F: FnMut(&/*mut ??*/ Self::Item) -> K,
        K: PartialEq;
}