| 1 | 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#; |
| 2 | |
| 3 | mod privaterust-analyzer cargo itertools 0.14.0 duplicates_impl/private/ { |
| 4 | 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#; |
| 5 | 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/; |
| 6 | 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#; |
| 7 | |
| 8 | #[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:)] |
| 9 | #[must_use = "iterator adaptors are lazy and do nothing unless consumed"] |
| 10 | pub struct DuplicatesByrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/DuplicatesBy#<I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#, Key, F> { |
| 11 | pub(craterust-analyzer cargo itertools 0.14.0 crate/) iterrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/DuplicatesBy#iter.: I, |
| 12 | pub(craterust-analyzer cargo itertools 0.14.0 crate/) metarust-analyzer cargo itertools 0.14.0 duplicates_impl/private/DuplicatesBy#meta.: Metarust-analyzer cargo itertools 0.14.0 duplicates_impl/private/Meta#<Key, F>, |
| 13 | } |
| 14 | |
| 15 | 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 DuplicatesByrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/DuplicatesBy#<I, V, F> |
| 16 | where |
| 17 | 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#, |
| 18 | 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#, |
| 19 | { |
| 20 | debug_fmt_fieldsrust-analyzer cargo itertools 0.14.0 impl_macros/debug_fmt_fields!!(DuplicatesBy, iterrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/DuplicatesBy#iter., metarust-analyzer cargo itertools 0.14.0 duplicates_impl/private/DuplicatesBy#meta..usedrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/Meta#used.); |
| 21 | } |
| 22 | |
| 23 | impl<I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#, Key: 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#, F> DuplicatesByrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/DuplicatesBy#<I, Key, F> { |
| 24 | pub(craterust-analyzer cargo itertools 0.14.0 crate/) fn newrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/impl#[`DuplicatesBy<I, Key, F>`]new().(iter: I, key_method: F) -> Selfrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/impl#[`DuplicatesBy<I, Key, F>`] { |
| 25 | Selfrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/impl#[`DuplicatesBy<I, Key, F>`] { |
| 26 | iterrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/DuplicatesBy#iter., |
| 27 | metarust-analyzer cargo itertools 0.14.0 duplicates_impl/private/DuplicatesBy#meta.: Metarust-analyzer cargo itertools 0.14.0 duplicates_impl/private/Meta# { |
| 28 | usedrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/Meta#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().(), |
| 29 | pendingrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/Meta#pending.: 0, |
| 30 | key_methodrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/Meta#key_method., |
| 31 | }, |
| 32 | } |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | #[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:)] |
| 37 | pub struct Metarust-analyzer cargo itertools 0.14.0 duplicates_impl/private/Meta#<Key, F> { |
| 38 | usedrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/Meta#used.: HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#<Key, bool>, |
| 39 | pendingrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/Meta#pending.: usize, |
| 40 | key_methodrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/Meta#key_method.: F, |
| 41 | } |
| 42 | |
| 43 | impl<Key, F> Metarust-analyzer cargo itertools 0.14.0 duplicates_impl/private/Meta#<Key, F> |
| 44 | where |
| 45 | Key: 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#, |
| 46 | { |
| 47 | /// Takes an item and returns it back to the caller if it's the second time we see it. |
| 48 | /// Otherwise the item is consumed and None is returned |
| 49 | #[inline(always)] |
| 50 | fn filterrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/impl#[`Meta<Key, F>`]filter().<I>(&mut self, item: I) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<I> |
| 51 | where |
| 52 | F: KeyMethodrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/KeyMethod#<Key, I>, |
| 53 | { |
| 54 | let kv = self.key_methodrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/Meta#key_method..makerust-analyzer cargo itertools 0.14.0 duplicates_impl/private/KeyMethod#make().(item); |
| 55 | match self.usedrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/Meta#used..get_mutrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get_mut().(kv.key_refrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/KeyXorValue#key_ref().()) { |
| 56 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => { |
| 57 | self.usedrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/Meta#used..insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().(kv.keyrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/KeyXorValue#key().(), false); |
| 58 | self.pendingrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/Meta#pending. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1; |
| 59 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 60 | } |
| 61 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(true) => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 62 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(produced) => { |
| 63 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().produced = true; |
| 64 | self.pendingrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/Meta#pending. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().1; |
| 65 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(kv.valuerust-analyzer cargo itertools 0.14.0 duplicates_impl/private/KeyXorValue#value().()) |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | impl<I, Key, F> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for DuplicatesByrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/DuplicatesBy#<I, Key, F> |
| 72 | where |
| 73 | I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#, |
| 74 | Key: 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#, |
| 75 | F: KeyMethodrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/KeyMethod#<Key, I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#>, |
| 76 | { |
| 77 | type Itemrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/impl#[`DuplicatesBy<I, Key, F>`][Iterator]Item# = I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#; |
| 78 | |
| 79 | fn nextrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/impl#[`DuplicatesBy<I, Key, 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 duplicates_impl/private/impl#[`DuplicatesBy<I, Key, F>`][Iterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> { |
| 80 | let Selfrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/impl#[`DuplicatesBy<I, Key, F>`][Iterator] { iterrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/DuplicatesBy#iter., metarust-analyzer cargo itertools 0.14.0 duplicates_impl/private/DuplicatesBy#meta. } = self; |
| 81 | iter.find_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#find_map().(|v| meta.filterrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/impl#[`Meta<Key, F>`]filter().(v)) |
| 82 | } |
| 83 | |
| 84 | #[inline] |
| 85 | fn size_hintrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/impl#[`DuplicatesBy<I, Key, F>`][Iterator]size_hint().(&self) -> (usize, Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>) { |
| 86 | let (_, hi) = self.iterrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/DuplicatesBy#iter..size_hintrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#size_hint().(); |
| 87 | let hi = hi.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|hi| { |
| 88 | if hi rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().self.metarust-analyzer cargo itertools 0.14.0 duplicates_impl/private/DuplicatesBy#meta..pendingrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/Meta#pending. { |
| 89 | // fewer or equally many iter-remaining elements than pending elements |
| 90 | // => at most, each iter-remaining element is matched |
| 91 | hi |
| 92 | } else { |
| 93 | // fewer pending elements than iter-remaining elements |
| 94 | // => at most: |
| 95 | // * each pending element is matched |
| 96 | // * the other iter-remaining elements come in pairs |
| 97 | self.metarust-analyzer cargo itertools 0.14.0 duplicates_impl/private/DuplicatesBy#meta..pendingrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/Meta#pending. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().(hi 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().self.metarust-analyzer cargo itertools 0.14.0 duplicates_impl/private/DuplicatesBy#meta..pendingrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/Meta#pending.) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div().2 |
| 98 | } |
| 99 | }); |
| 100 | // The lower bound is always 0 since we might only get unique items from now on |
| 101 | (0, hi) |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | impl<I, Key, F> DoubleEndedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/double_ended/DoubleEndedIterator# for DuplicatesByrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/DuplicatesBy#<I, Key, F> |
| 106 | where |
| 107 | I: DoubleEndedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/double_ended/DoubleEndedIterator#, |
| 108 | Key: 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#, |
| 109 | F: KeyMethodrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/KeyMethod#<Key, I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#>, |
| 110 | { |
| 111 | fn next_backrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/impl#[`DuplicatesBy<I, Key, 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 duplicates_impl/private/impl#[`DuplicatesBy<I, Key, F>`][DoubleEndedIterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> { |
| 112 | let Selfrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/impl#[`DuplicatesBy<I, Key, F>`][DoubleEndedIterator] { iterrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/DuplicatesBy#iter., metarust-analyzer cargo itertools 0.14.0 duplicates_impl/private/DuplicatesBy#meta. } = self; |
| 113 | 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| meta.filterrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/impl#[`Meta<Key, F>`]filter().(v)) |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | /// A keying method for use with `DuplicatesBy` |
| 118 | pub trait KeyMethodrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/KeyMethod#<K, V> { |
| 119 | type Containerrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/KeyMethod#Container#: KeyXorValuerust-analyzer cargo itertools 0.14.0 duplicates_impl/private/KeyXorValue#<K, V>; |
| 120 | |
| 121 | fn makerust-analyzer cargo itertools 0.14.0 duplicates_impl/private/KeyMethod#make().(&mut self, value: V) -> Self::Containerrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/KeyMethod#Container#; |
| 122 | } |
| 123 | |
| 124 | /// Apply the identity function to elements before checking them for equality. |
| 125 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 126 | pub struct ByIdrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/ById#; |
| 127 | impl<V> KeyMethodrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/KeyMethod#<V, V> for ByIdrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/ById# { |
| 128 | type Containerrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/impl#[ById][`KeyMethod<V, V>`]Container# = JustValuerust-analyzer cargo itertools 0.14.0 duplicates_impl/private/JustValue#<V>; |
| 129 | |
| 130 | fn makerust-analyzer cargo itertools 0.14.0 duplicates_impl/private/impl#[ById][`KeyMethod<V, V>`]make().(&mut self, v: V) -> Selfrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/impl#[ById][`KeyMethod<V, V>`]::Containerrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/KeyMethod#Container# { |
| 131 | JustValuerust-analyzer cargo itertools 0.14.0 duplicates_impl/private/JustValue#(v) |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | /// Apply a user-supplied function to elements before checking them for equality. |
| 136 | #[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:)] |
| 137 | pub struct ByFnrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/ByFn#<F>(pub(craterust-analyzer cargo itertools 0.14.0 crate/) F); |
| 138 | impl<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 ByFnrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/ByFn#<F> { |
| 139 | debug_fmt_fieldsrust-analyzer cargo itertools 0.14.0 impl_macros/debug_fmt_fields!!(ByFn,); |
| 140 | } |
| 141 | impl<K, V, F> KeyMethodrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/KeyMethod#<K, V> for ByFnrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/ByFn#<F> |
| 142 | where |
| 143 | F: FnMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnMut#(&V) -> K, |
| 144 | { |
| 145 | type Containerrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/impl#[`ByFn<F>`][`KeyMethod<K, V>`]Container# = KeyValuerust-analyzer cargo itertools 0.14.0 duplicates_impl/private/KeyValue#<K, V>; |
| 146 | |
| 147 | fn makerust-analyzer cargo itertools 0.14.0 duplicates_impl/private/impl#[`ByFn<F>`][`KeyMethod<K, V>`]make().(&mut self, v: V) -> Selfrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/impl#[`ByFn<F>`][`KeyMethod<K, V>`]::Containerrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/KeyMethod#Container# { |
| 148 | KeyValuerust-analyzer cargo itertools 0.14.0 duplicates_impl/private/KeyValue#((self.0rust-analyzer cargo itertools 0.14.0 duplicates_impl/private/ByFn#0.)(&v), v) |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | // Implementors of this trait can hold onto a key and a value but only give access to one of them |
| 153 | // at a time. This allows the key and the value to be the same value internally |
| 154 | pub trait KeyXorValuerust-analyzer cargo itertools 0.14.0 duplicates_impl/private/KeyXorValue#<K, V> { |
| 155 | fn key_refrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/KeyXorValue#key_ref().(&self) -> &K; |
| 156 | fn keyrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/KeyXorValue#key().(self) -> K; |
| 157 | fn valuerust-analyzer cargo itertools 0.14.0 duplicates_impl/private/KeyXorValue#value().(self) -> V; |
| 158 | } |
| 159 | |
| 160 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 161 | pub struct KeyValuerust-analyzer cargo itertools 0.14.0 duplicates_impl/private/KeyValue#<K, V>(K, V); |
| 162 | impl<K, V> KeyXorValuerust-analyzer cargo itertools 0.14.0 duplicates_impl/private/KeyXorValue#<K, V> for KeyValuerust-analyzer cargo itertools 0.14.0 duplicates_impl/private/KeyValue#<K, V> { |
| 163 | fn key_refrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/impl#[`KeyValue<K, V>`][`KeyXorValue<K, V>`]key_ref().(&self) -> &K { |
| 164 | &self.0rust-analyzer cargo itertools 0.14.0 duplicates_impl/private/KeyValue#0. |
| 165 | } |
| 166 | fn keyrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/impl#[`KeyValue<K, V>`][`KeyXorValue<K, V>`]key().(self) -> K { |
| 167 | self.0rust-analyzer cargo itertools 0.14.0 duplicates_impl/private/KeyValue#0. |
| 168 | } |
| 169 | fn valuerust-analyzer cargo itertools 0.14.0 duplicates_impl/private/impl#[`KeyValue<K, V>`][`KeyXorValue<K, V>`]value().(self) -> V { |
| 170 | self.1rust-analyzer cargo itertools 0.14.0 duplicates_impl/private/KeyValue#1. |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 175 | pub struct JustValuerust-analyzer cargo itertools 0.14.0 duplicates_impl/private/JustValue#<V>(V); |
| 176 | impl<V> KeyXorValuerust-analyzer cargo itertools 0.14.0 duplicates_impl/private/KeyXorValue#<V, V> for JustValuerust-analyzer cargo itertools 0.14.0 duplicates_impl/private/JustValue#<V> { |
| 177 | fn key_refrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/impl#[`JustValue<V>`][`KeyXorValue<V, V>`]key_ref().(&self) -> &V { |
| 178 | &self.0rust-analyzer cargo itertools 0.14.0 duplicates_impl/private/JustValue#0. |
| 179 | } |
| 180 | fn keyrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/impl#[`JustValue<V>`][`KeyXorValue<V, V>`]key().(self) -> V { |
| 181 | self.0rust-analyzer cargo itertools 0.14.0 duplicates_impl/private/JustValue#0. |
| 182 | } |
| 183 | fn valuerust-analyzer cargo itertools 0.14.0 duplicates_impl/private/impl#[`JustValue<V>`][`KeyXorValue<V, V>`]value().(self) -> V { |
| 184 | self.0rust-analyzer cargo itertools 0.14.0 duplicates_impl/private/JustValue#0. |
| 185 | } |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | /// An iterator adapter to filter for duplicate elements. |
| 190 | /// |
| 191 | /// See [`.duplicates_by()`](crate::Itertools::duplicates_by) for more information. |
| 192 | pub type DuplicatesByrust-analyzer cargo itertools 0.14.0 duplicates_impl/DuplicatesBy#<I, V, F> = privaterust-analyzer cargo itertools 0.14.0 duplicates_impl/private/::DuplicatesByrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/DuplicatesBy#<I, V, privaterust-analyzer cargo itertools 0.14.0 duplicates_impl/private/::ByFnrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/ByFn#<F>>; |
| 193 | |
| 194 | /// Create a new `DuplicatesBy` iterator. |
| 195 | pub fn duplicates_byrust-analyzer cargo itertools 0.14.0 duplicates_impl/duplicates_by().<I, Key, F>(iter: I, f: F) -> DuplicatesByrust-analyzer cargo itertools 0.14.0 duplicates_impl/DuplicatesBy#<I, Key, F> |
| 196 | where |
| 197 | Key: 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#, |
| 198 | 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#) -> Key, |
| 199 | I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#, |
| 200 | { |
| 201 | DuplicatesByrust-analyzer cargo itertools 0.14.0 duplicates_impl/DuplicatesBy#::newrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/impl#[`DuplicatesBy<I, Key, F>`]new().(iter, privaterust-analyzer cargo itertools 0.14.0 duplicates_impl/private/::ByFnrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/ByFn#(f)) |
| 202 | } |
| 203 | |
| 204 | /// An iterator adapter to filter out duplicate elements. |
| 205 | /// |
| 206 | /// See [`.duplicates()`](crate::Itertools::duplicates) for more information. |
| 207 | pub type Duplicatesrust-analyzer cargo itertools 0.14.0 duplicates_impl/Duplicates#<I> = privaterust-analyzer cargo itertools 0.14.0 duplicates_impl/private/::DuplicatesByrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/DuplicatesBy#<I, <I as Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#>::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#, privaterust-analyzer cargo itertools 0.14.0 duplicates_impl/private/::ByIdrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/ById#>; |
| 208 | |
| 209 | /// Create a new `Duplicates` iterator. |
| 210 | pub fn duplicatesrust-analyzer cargo itertools 0.14.0 duplicates_impl/duplicates().<I>(iter: I) -> Duplicatesrust-analyzer cargo itertools 0.14.0 duplicates_impl/Duplicates#<I> |
| 211 | where |
| 212 | I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#, |
| 213 | 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#, |
| 214 | { |
| 215 | Duplicatesrust-analyzer cargo itertools 0.14.0 duplicates_impl/Duplicates#::newrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/impl#[`DuplicatesBy<I, Key, F>`]new().(iter, privaterust-analyzer cargo itertools 0.14.0 duplicates_impl/private/::ByIdrust-analyzer cargo itertools 0.14.0 duplicates_impl/private/ById#) |
| 216 | } |