| 1 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::hash_maprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash_map/::Entryrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/Entry#; |
| 2 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#; |
| 3 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/; |
| 4 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::hashrust-analyzer cargo std https://github.com/rust-lang/rust/library/std hash/::Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#; |
| 5 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::FusedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/marker/FusedIterator#; |
| 6 | |
| 7 | /// An iterator adapter to filter out duplicate elements. |
| 8 | /// |
| 9 | /// See [`.unique_by()`](crate::Itertools::unique) for more information. |
| 10 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 11 | #[must_use = "iterator adaptors are lazy and do nothing unless consumed"] |
| 12 | pub struct UniqueByrust-analyzer cargo itertools 0.14.0 unique_impl/UniqueBy#<I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#, V, F> { |
| 13 | iterrust-analyzer cargo itertools 0.14.0 unique_impl/UniqueBy#iter.: I, |
| 14 | // Use a Hashmap for the Entry API in order to prevent hashing twice. |
| 15 | // This can maybe be replaced with a HashSet once `get_or_insert_with` |
| 16 | // or a proper Entry API for Hashset is stable and meets this msrv |
| 17 | usedrust-analyzer cargo itertools 0.14.0 unique_impl/UniqueBy#used.: HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#<V, ()>, |
| 18 | frust-analyzer cargo itertools 0.14.0 unique_impl/UniqueBy#f.: F, |
| 19 | } |
| 20 | |
| 21 | impl<I, V, F> fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# for UniqueByrust-analyzer cargo itertools 0.14.0 unique_impl/UniqueBy#<I, V, F> |
| 22 | where |
| 23 | I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# + fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#, |
| 24 | V: fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash# + Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq#, |
| 25 | { |
| 26 | debug_fmt_fieldsrust-analyzer cargo itertools 0.14.0 impl_macros/debug_fmt_fields!!(UniqueBy, iterrust-analyzer cargo itertools 0.14.0 unique_impl/UniqueBy#iter., usedrust-analyzer cargo itertools 0.14.0 unique_impl/UniqueBy#used.); |
| 27 | } |
| 28 | |
| 29 | /// Create a new `UniqueBy` iterator. |
| 30 | pub fn unique_byrust-analyzer cargo itertools 0.14.0 unique_impl/unique_by().<I, V, F>(iter: I, f: F) -> UniqueByrust-analyzer cargo itertools 0.14.0 unique_impl/UniqueBy#<I, V, F> |
| 31 | where |
| 32 | V: Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#, |
| 33 | F: FnMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnMut#(&I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#) -> V, |
| 34 | I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#, |
| 35 | { |
| 36 | UniqueByrust-analyzer cargo itertools 0.14.0 unique_impl/UniqueBy# { |
| 37 | iterrust-analyzer cargo itertools 0.14.0 unique_impl/UniqueBy#iter., |
| 38 | usedrust-analyzer cargo itertools 0.14.0 unique_impl/UniqueBy#used.: HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V>`]new().(), |
| 39 | frust-analyzer cargo itertools 0.14.0 unique_impl/UniqueBy#f., |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | // count the number of new unique keys in iterable (`used` is the set already seen) |
| 44 | fn count_new_keysrust-analyzer cargo itertools 0.14.0 unique_impl/count_new_keys().<I, K>(mut used: HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#<K, ()>, iterable: I) -> usize |
| 45 | where |
| 46 | I: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = K>, |
| 47 | K: Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash# + Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq#, |
| 48 | { |
| 49 | let iter = iterable.into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#into_iter().(); |
| 50 | let current_used = used.lenrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]len().(); |
| 51 | used.extendrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`][`Extend<(K, V)>`]extend().(iter.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|key| (key, ()))); |
| 52 | used.lenrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().current_used |
| 53 | } |
| 54 | |
| 55 | impl<I, V, F> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for UniqueByrust-analyzer cargo itertools 0.14.0 unique_impl/UniqueBy#<I, V, F> |
| 56 | where |
| 57 | I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#, |
| 58 | V: Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#, |
| 59 | F: FnMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnMut#(&I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#) -> V, |
| 60 | { |
| 61 | type Itemrust-analyzer cargo itertools 0.14.0 unique_impl/impl#[`UniqueBy<I, V, F>`][Iterator]Item# = I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#; |
| 62 | |
| 63 | fn nextrust-analyzer cargo itertools 0.14.0 unique_impl/impl#[`UniqueBy<I, V, F>`][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo itertools 0.14.0 unique_impl/impl#[`UniqueBy<I, V, F>`][Iterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> { |
| 64 | let Selfrust-analyzer cargo itertools 0.14.0 unique_impl/impl#[`UniqueBy<I, V, F>`][Iterator] { iterrust-analyzer cargo itertools 0.14.0 unique_impl/UniqueBy#iter., usedrust-analyzer cargo itertools 0.14.0 unique_impl/UniqueBy#used., frust-analyzer cargo itertools 0.14.0 unique_impl/UniqueBy#f. } = self; |
| 65 | iter.findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#find().(|v| used.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().(f(v), ()).is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().()) |
| 66 | } |
| 67 | |
| 68 | #[inline] |
| 69 | fn size_hintrust-analyzer cargo itertools 0.14.0 unique_impl/impl#[`UniqueBy<I, V, F>`][Iterator]size_hint().(&self) -> (usize, Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>) { |
| 70 | let (low, hi) = self.iterrust-analyzer cargo itertools 0.14.0 unique_impl/UniqueBy#iter..size_hintrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#size_hint().(); |
| 71 | ((low rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().0 && self.usedrust-analyzer cargo itertools 0.14.0 unique_impl/UniqueBy#used..is_emptyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]is_empty().()) as usize, hi) |
| 72 | } |
| 73 | |
| 74 | fn countrust-analyzer cargo itertools 0.14.0 unique_impl/impl#[`UniqueBy<I, V, F>`][Iterator]count().(self) -> usize { |
| 75 | let mut key_f = self.frust-analyzer cargo itertools 0.14.0 unique_impl/UniqueBy#f.; |
| 76 | count_new_keysrust-analyzer cargo itertools 0.14.0 unique_impl/count_new_keys().(self.usedrust-analyzer cargo itertools 0.14.0 unique_impl/UniqueBy#used., self.iterrust-analyzer cargo itertools 0.14.0 unique_impl/UniqueBy#iter..maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(move |elt| key_f(&elt))) |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | impl<I, V, F> DoubleEndedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/double_ended/DoubleEndedIterator# for UniqueByrust-analyzer cargo itertools 0.14.0 unique_impl/UniqueBy#<I, V, F> |
| 81 | where |
| 82 | I: DoubleEndedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/double_ended/DoubleEndedIterator#, |
| 83 | V: Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#, |
| 84 | F: FnMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnMut#(&I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#) -> V, |
| 85 | { |
| 86 | fn next_backrust-analyzer cargo itertools 0.14.0 unique_impl/impl#[`UniqueBy<I, V, F>`][DoubleEndedIterator]next_back().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo itertools 0.14.0 unique_impl/impl#[`UniqueBy<I, V, F>`][DoubleEndedIterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> { |
| 87 | let Selfrust-analyzer cargo itertools 0.14.0 unique_impl/impl#[`UniqueBy<I, V, F>`][DoubleEndedIterator] { iterrust-analyzer cargo itertools 0.14.0 unique_impl/UniqueBy#iter., usedrust-analyzer cargo itertools 0.14.0 unique_impl/UniqueBy#used., frust-analyzer cargo itertools 0.14.0 unique_impl/UniqueBy#f. } = self; |
| 88 | iter.rfindrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/double_ended/DoubleEndedIterator#rfind().(|v| used.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().(f(v), ()).is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().()) |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | impl<I, V, F> FusedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/marker/FusedIterator# for UniqueByrust-analyzer cargo itertools 0.14.0 unique_impl/UniqueBy#<I, V, F> |
| 93 | where |
| 94 | I: FusedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/marker/FusedIterator#, |
| 95 | V: Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#, |
| 96 | F: FnMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnMut#(&I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#) -> V, |
| 97 | { |
| 98 | } |
| 99 | |
| 100 | impl<I> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for Uniquerust-analyzer cargo itertools 0.14.0 unique_impl/Unique#<I> |
| 101 | where |
| 102 | I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#, |
| 103 | I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#: Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#, |
| 104 | { |
| 105 | type Itemrust-analyzer cargo itertools 0.14.0 unique_impl/impl#[`Unique<I>`][Iterator]Item# = I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#; |
| 106 | |
| 107 | fn nextrust-analyzer cargo itertools 0.14.0 unique_impl/impl#[`Unique<I>`][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo itertools 0.14.0 unique_impl/impl#[`Unique<I>`][Iterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> { |
| 108 | let UniqueByrust-analyzer cargo itertools 0.14.0 unique_impl/UniqueBy# { iterrust-analyzer cargo itertools 0.14.0 unique_impl/UniqueBy#iter., usedrust-analyzer cargo itertools 0.14.0 unique_impl/UniqueBy#used., .. } = &mut self.iterrust-analyzer cargo itertools 0.14.0 unique_impl/Unique#iter.; |
| 109 | iter.find_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#find_map().(|v| { |
| 110 | if let Entryrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/Entry#::Vacantrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/Entry#Vacant#(entry) = used.entryrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]entry().(v) { |
| 111 | let elt = entry.keyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`VacantEntry<'a, K, V, A>`]key().().clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(); |
| 112 | entry.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`VacantEntry<'a, K, V, A>`]insert().(()); |
| 113 | return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(elt); |
| 114 | } |
| 115 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 116 | }) |
| 117 | } |
| 118 | |
| 119 | #[inline] |
| 120 | fn size_hintrust-analyzer cargo itertools 0.14.0 unique_impl/impl#[`Unique<I>`][Iterator]size_hint().(&self) -> (usize, Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>) { |
| 121 | let (low, hi) = self.iterrust-analyzer cargo itertools 0.14.0 unique_impl/Unique#iter..iterrust-analyzer cargo itertools 0.14.0 unique_impl/UniqueBy#iter..size_hintrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#size_hint().(); |
| 122 | ((low rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().0 && self.iterrust-analyzer cargo itertools 0.14.0 unique_impl/Unique#iter..usedrust-analyzer cargo itertools 0.14.0 unique_impl/UniqueBy#used..is_emptyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]is_empty().()) as usize, hi) |
| 123 | } |
| 124 | |
| 125 | fn countrust-analyzer cargo itertools 0.14.0 unique_impl/impl#[`Unique<I>`][Iterator]count().(self) -> usize { |
| 126 | count_new_keysrust-analyzer cargo itertools 0.14.0 unique_impl/count_new_keys().(self.iterrust-analyzer cargo itertools 0.14.0 unique_impl/Unique#iter..usedrust-analyzer cargo itertools 0.14.0 unique_impl/UniqueBy#used., self.iterrust-analyzer cargo itertools 0.14.0 unique_impl/Unique#iter..iterrust-analyzer cargo itertools 0.14.0 unique_impl/UniqueBy#iter.) |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | impl<I> DoubleEndedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/double_ended/DoubleEndedIterator# for Uniquerust-analyzer cargo itertools 0.14.0 unique_impl/Unique#<I> |
| 131 | where |
| 132 | I: DoubleEndedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/double_ended/DoubleEndedIterator#, |
| 133 | I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#: Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#, |
| 134 | { |
| 135 | fn next_backrust-analyzer cargo itertools 0.14.0 unique_impl/impl#[`Unique<I>`][DoubleEndedIterator]next_back().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo itertools 0.14.0 unique_impl/impl#[`Unique<I>`][DoubleEndedIterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> { |
| 136 | let UniqueByrust-analyzer cargo itertools 0.14.0 unique_impl/UniqueBy# { iterrust-analyzer cargo itertools 0.14.0 unique_impl/UniqueBy#iter., usedrust-analyzer cargo itertools 0.14.0 unique_impl/UniqueBy#used., .. } = &mut self.iterrust-analyzer cargo itertools 0.14.0 unique_impl/Unique#iter.; |
| 137 | iter.revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#rev().().find_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#find_map().(|v| { |
| 138 | if let Entryrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/Entry#::Vacantrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/Entry#Vacant#(entry) = used.entryrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]entry().(v) { |
| 139 | let elt = entry.keyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`VacantEntry<'a, K, V, A>`]key().().clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(); |
| 140 | entry.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`VacantEntry<'a, K, V, A>`]insert().(()); |
| 141 | return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(elt); |
| 142 | } |
| 143 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 144 | }) |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | impl<I> FusedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/marker/FusedIterator# for Uniquerust-analyzer cargo itertools 0.14.0 unique_impl/Unique#<I> |
| 149 | where |
| 150 | I: FusedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/marker/FusedIterator#, |
| 151 | I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#: Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#, |
| 152 | { |
| 153 | } |
| 154 | |
| 155 | /// An iterator adapter to filter out duplicate elements. |
| 156 | /// |
| 157 | /// See [`.unique()`](crate::Itertools::unique) for more information. |
| 158 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 159 | #[must_use = "iterator adaptors are lazy and do nothing unless consumed"] |
| 160 | pub struct Uniquerust-analyzer cargo itertools 0.14.0 unique_impl/Unique#<I> |
| 161 | where |
| 162 | I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#, |
| 163 | I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#: Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#, |
| 164 | { |
| 165 | iterrust-analyzer cargo itertools 0.14.0 unique_impl/Unique#iter.: UniqueByrust-analyzer cargo itertools 0.14.0 unique_impl/UniqueBy#<I, I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#, ()>, |
| 166 | } |
| 167 | |
| 168 | impl<I> fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# for Uniquerust-analyzer cargo itertools 0.14.0 unique_impl/Unique#<I> |
| 169 | where |
| 170 | I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# + fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#, |
| 171 | I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#: Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash# + Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#, |
| 172 | { |
| 173 | debug_fmt_fieldsrust-analyzer cargo itertools 0.14.0 impl_macros/debug_fmt_fields!!(Unique, iterrust-analyzer cargo itertools 0.14.0 unique_impl/Unique#iter.); |
| 174 | } |
| 175 | |
| 176 | pub fn uniquerust-analyzer cargo itertools 0.14.0 unique_impl/unique().<I>(iter: I) -> Uniquerust-analyzer cargo itertools 0.14.0 unique_impl/Unique#<I> |
| 177 | where |
| 178 | I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#, |
| 179 | I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#: Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#, |
| 180 | { |
| 181 | Uniquerust-analyzer cargo itertools 0.14.0 unique_impl/Unique# { |
| 182 | iterrust-analyzer cargo itertools 0.14.0 unique_impl/Unique#iter.: UniqueByrust-analyzer cargo itertools 0.14.0 unique_impl/UniqueBy# { |
| 183 | iterrust-analyzer cargo itertools 0.14.0 unique_impl/UniqueBy#iter., |
| 184 | usedrust-analyzer cargo itertools 0.14.0 unique_impl/UniqueBy#used.: HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V>`]new().(), |
| 185 | frust-analyzer cargo itertools 0.14.0 unique_impl/UniqueBy#f.: (), |
| 186 | }, |
| 187 | } |
| 188 | } |