| 1 | use allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/::{selfrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/, Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#}; |
| 2 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::cellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/::{Cellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/Cell#, RefCellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/RefCell#}; |
| 3 | |
| 4 | /// A trait to unify `FnMut` for `ChunkBy` with the chunk key in `IntoChunks` |
| 5 | trait KeyFunctionrust-analyzer cargo itertools 0.14.0 groupbylazy/KeyFunction#<A> { |
| 6 | type Keyrust-analyzer cargo itertools 0.14.0 groupbylazy/KeyFunction#Key#; |
| 7 | fn call_mutrust-analyzer cargo itertools 0.14.0 groupbylazy/KeyFunction#call_mut().(&mut self, arg: A) -> Self::Keyrust-analyzer cargo itertools 0.14.0 groupbylazy/KeyFunction#Key#; |
| 8 | } |
| 9 | |
| 10 | impl<A, K, F> KeyFunctionrust-analyzer cargo itertools 0.14.0 groupbylazy/KeyFunction#<A> for F |
| 11 | where |
| 12 | F: FnMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnMut#(A) -> K + ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#, |
| 13 | { |
| 14 | type Keyrust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[F][`KeyFunction<A>`]Key# = K; |
| 15 | #[inline] |
| 16 | fn call_mutrust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[F][`KeyFunction<A>`]call_mut().(&mut self, arg: A) -> Selfrust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[F][`KeyFunction<A>`]::Keyrust-analyzer cargo itertools 0.14.0 groupbylazy/KeyFunction#Key# { |
| 17 | (*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().self)(arg) |
| 18 | } |
| 19 | } |
| 20 | |
| 21 | /// `ChunkIndex` acts like the grouping key function for `IntoChunks` |
| 22 | #[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:)] |
| 23 | struct ChunkIndexrust-analyzer cargo itertools 0.14.0 groupbylazy/ChunkIndex# { |
| 24 | sizerust-analyzer cargo itertools 0.14.0 groupbylazy/ChunkIndex#size.: usize, |
| 25 | indexrust-analyzer cargo itertools 0.14.0 groupbylazy/ChunkIndex#index.: usize, |
| 26 | keyrust-analyzer cargo itertools 0.14.0 groupbylazy/ChunkIndex#key.: usize, |
| 27 | } |
| 28 | |
| 29 | impl ChunkIndexrust-analyzer cargo itertools 0.14.0 groupbylazy/ChunkIndex# { |
| 30 | #[inline(always)] |
| 31 | fn newrust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[ChunkIndex]new().(size: usize) -> Selfrust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[ChunkIndex] { |
| 32 | Selfrust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[ChunkIndex] { |
| 33 | sizerust-analyzer cargo itertools 0.14.0 groupbylazy/ChunkIndex#size., |
| 34 | indexrust-analyzer cargo itertools 0.14.0 groupbylazy/ChunkIndex#index.: 0, |
| 35 | keyrust-analyzer cargo itertools 0.14.0 groupbylazy/ChunkIndex#key.: 0, |
| 36 | } |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | impl<A> KeyFunctionrust-analyzer cargo itertools 0.14.0 groupbylazy/KeyFunction#<A> for ChunkIndexrust-analyzer cargo itertools 0.14.0 groupbylazy/ChunkIndex# { |
| 41 | type Keyrust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[ChunkIndex][`KeyFunction<A>`]Key# = usize; |
| 42 | #[inline(always)] |
| 43 | fn call_mutrust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[ChunkIndex][`KeyFunction<A>`]call_mut().(&mut self, _arg: A) -> Selfrust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[ChunkIndex][`KeyFunction<A>`]::Keyrust-analyzer cargo itertools 0.14.0 groupbylazy/KeyFunction#Key# { |
| 44 | if self.indexrust-analyzer cargo itertools 0.14.0 groupbylazy/ChunkIndex#index. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().self.sizerust-analyzer cargo itertools 0.14.0 groupbylazy/ChunkIndex#size. { |
| 45 | self.keyrust-analyzer cargo itertools 0.14.0 groupbylazy/ChunkIndex#key. 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; |
| 46 | self.indexrust-analyzer cargo itertools 0.14.0 groupbylazy/ChunkIndex#index. = 0; |
| 47 | } |
| 48 | self.indexrust-analyzer cargo itertools 0.14.0 groupbylazy/ChunkIndex#index. 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; |
| 49 | self.keyrust-analyzer cargo itertools 0.14.0 groupbylazy/ChunkIndex#key. |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | #[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:)] |
| 54 | struct GroupInnerrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#<K, I, F> |
| 55 | where |
| 56 | I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#, |
| 57 | { |
| 58 | keyrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#key.: F, |
| 59 | iterrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#iter.: I, |
| 60 | current_keyrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#current_key.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<K>, |
| 61 | current_eltrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#current_elt.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#>, |
| 62 | /// flag set if iterator is exhausted |
| 63 | donerust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#done.: bool, |
| 64 | /// Index of group we are currently buffering or visiting |
| 65 | top_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#top_group.: usize, |
| 66 | /// Least index for which we still have elements buffered |
| 67 | oldest_buffered_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#oldest_buffered_group.: usize, |
| 68 | /// Group index for `buffer[0]` -- the slots |
| 69 | /// `bottom_group..oldest_buffered_group` are unused and will be erased when |
| 70 | /// that range is large enough. |
| 71 | bottom_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#bottom_group.: usize, |
| 72 | /// Buffered groups, from `bottom_group` (index 0) to `top_group`. |
| 73 | bufferrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#buffer.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/::IntoIterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/into_iter/IntoIter#<I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#>>, |
| 74 | /// index of last group iter that was dropped, |
| 75 | /// `usize::MAX` initially when no group was dropped |
| 76 | dropped_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#dropped_group.: usize, |
| 77 | } |
| 78 | |
| 79 | impl<K, I, F> GroupInnerrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#<K, I, F> |
| 80 | where |
| 81 | I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#, |
| 82 | F: for<'a> KeyFunctionrust-analyzer cargo itertools 0.14.0 groupbylazy/KeyFunction#<&'a I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#, Keyrust-analyzer cargo itertools 0.14.0 groupbylazy/KeyFunction#Key# = K>, |
| 83 | K: PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#, |
| 84 | { |
| 85 | /// `client`: Index of group that requests next element |
| 86 | #[inline(always)] |
| 87 | fn steprust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[`GroupInner<K, I, F>`]step().(&mut self, client: usize) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> { |
| 88 | /* |
| 89 | println!("client={}, bottom_group={}, oldest_buffered_group={}, top_group={}, buffers=[{}]", |
| 90 | client, self.bottom_group, self.oldest_buffered_group, |
| 91 | self.top_group, |
| 92 | self.buffer.iter().map(|elt| elt.len()).format(", ")); |
| 93 | */ |
| 94 | if client rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().self.oldest_buffered_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#oldest_buffered_group. { |
| 95 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 96 | } else if client rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().self.top_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#top_group. |
| 97 | || (client rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().self.top_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#top_group. && self.bufferrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#buffer..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() 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().self.top_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#top_group. 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.bottom_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#bottom_group.) |
| 98 | { |
| 99 | self.lookup_bufferrust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[`GroupInner<K, I, F>`]lookup_buffer().(client) |
| 100 | } else if self.donerust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#done. { |
| 101 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 102 | } else if self.top_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#top_group. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().client { |
| 103 | self.step_currentrust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[`GroupInner<K, I, F>`]step_current().() |
| 104 | } else { |
| 105 | self.step_bufferingrust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[`GroupInner<K, I, F>`]step_buffering().(client) |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | #[inline(never)] |
| 110 | fn lookup_bufferrust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[`GroupInner<K, I, F>`]lookup_buffer().(&mut self, client: usize) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> { |
| 111 | // if `bufidx` doesn't exist in self.buffer, it might be empty |
| 112 | let bufidx = client 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.bottom_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#bottom_group.; |
| 113 | if client rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().self.oldest_buffered_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#oldest_buffered_group. { |
| 114 | return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 115 | } |
| 116 | let elt = self.bufferrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#buffer..get_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get_mut().(bufidx).and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|queue| queue.nextrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/into_iter/impl#[`IntoIter<T, A>`][Iterator]next().()); |
| 117 | if elt.is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().() && client rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().self.oldest_buffered_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#oldest_buffered_group. { |
| 118 | // FIXME: VecDeque is unfortunately not zero allocation when empty, |
| 119 | // so we do this job manually. |
| 120 | // `bottom_group..oldest_buffered_group` is unused, and if it's large enough, erase it. |
| 121 | self.oldest_buffered_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#oldest_buffered_group. 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; |
| 122 | // skip forward further empty queues too |
| 123 | while self |
| 124 | .bufferrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#buffer. |
| 125 | .getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(self.oldest_buffered_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#oldest_buffered_group. 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.bottom_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#bottom_group.) |
| 126 | .map_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map_or().(false, |buf| buf.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/exact_size/ExactSizeIterator#len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0) |
| 127 | { |
| 128 | self.oldest_buffered_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#oldest_buffered_group. 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; |
| 129 | } |
| 130 | |
| 131 | let nclear = self.oldest_buffered_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#oldest_buffered_group. 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.bottom_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#bottom_group.; |
| 132 | if nclear 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 && nclear rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().self.bufferrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#buffer..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() 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 { |
| 133 | let mut i = 0; |
| 134 | self.bufferrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#buffer..retainrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]retain().(|buf| { |
| 135 | i 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; |
| 136 | debug_assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert!!(buf.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/exact_size/ExactSizeIterator#len().() == 0 || i >rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). nclear); |
| 137 | i 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().nclear |
| 138 | }); |
| 139 | self.bottom_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#bottom_group. = self.oldest_buffered_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#oldest_buffered_group.; |
| 140 | } |
| 141 | } |
| 142 | elt |
| 143 | } |
| 144 | |
| 145 | /// Take the next element from the iterator, and set the done |
| 146 | /// flag if exhausted. Must not be called after done. |
| 147 | #[inline(always)] |
| 148 | fn next_elementrust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[`GroupInner<K, I, F>`]next_element().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> { |
| 149 | debug_assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.donerust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#done.); |
| 150 | match self.iterrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#iter..nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#next().() { |
| 151 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => { |
| 152 | self.donerust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#done. = true; |
| 153 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 154 | } |
| 155 | otherwise => otherwise, |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | #[inline(never)] |
| 160 | fn step_bufferingrust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[`GroupInner<K, I, F>`]step_buffering().(&mut self, client: usize) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> { |
| 161 | // requested a later group -- walk through the current group up to |
| 162 | // the requested group index, and buffer the elements (unless |
| 163 | // the group is marked as dropped). |
| 164 | // Because the `Groups` iterator is always the first to request |
| 165 | // each group index, client is the next index efter top_group. |
| 166 | debug_assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert!!(self.top_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#top_group. +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). 1 == client); |
| 167 | let mut group = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); |
| 168 | |
| 169 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(elt) = self.current_eltrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#current_elt..takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]take().() { |
| 170 | if self.top_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#top_group. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().self.dropped_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#dropped_group. { |
| 171 | group.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(elt); |
| 172 | } |
| 173 | } |
| 174 | let mut first_elt = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; // first element of the next group |
| 175 | |
| 176 | while let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(elt) = self.next_elementrust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[`GroupInner<K, I, F>`]next_element().() { |
| 177 | let key = self.keyrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#key..call_mutrust-analyzer cargo itertools 0.14.0 groupbylazy/KeyFunction#call_mut().(&elt); |
| 178 | match self.current_keyrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#current_key..takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]take().() { |
| 179 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => {} |
| 180 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(old_key) => { |
| 181 | if old_key rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().key { |
| 182 | self.current_keyrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#current_key. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(key); |
| 183 | first_elt = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(elt); |
| 184 | break; |
| 185 | } |
| 186 | } |
| 187 | } |
| 188 | self.current_keyrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#current_key. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(key); |
| 189 | if self.top_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#top_group. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().self.dropped_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#dropped_group. { |
| 190 | group.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(elt); |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | if self.top_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#top_group. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().self.dropped_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#dropped_group. { |
| 195 | self.push_next_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[`GroupInner<K, I, F>`]push_next_group().(group); |
| 196 | } |
| 197 | if first_elt.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() { |
| 198 | self.top_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#top_group. 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; |
| 199 | debug_assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert!!(self.top_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#top_group. == client); |
| 200 | } |
| 201 | first_elt |
| 202 | } |
| 203 | |
| 204 | fn push_next_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[`GroupInner<K, I, F>`]push_next_group().(&mut self, group: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#>) { |
| 205 | // When we add a new buffered group, fill up slots between oldest_buffered_group and top_group |
| 206 | while self.top_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#top_group. 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.bottom_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#bottom_group. 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().self.bufferrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#buffer..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() { |
| 207 | if self.bufferrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#buffer..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() { |
| 208 | self.bottom_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#bottom_group. 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; |
| 209 | self.oldest_buffered_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#oldest_buffered_group. 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; |
| 210 | } else { |
| 211 | self.bufferrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#buffer..pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().().into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().()); |
| 212 | } |
| 213 | } |
| 214 | self.bufferrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#buffer..pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(group.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().()); |
| 215 | debug_assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert!!(self.top_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#top_group. +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). 1 -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). self.bottom_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#bottom_group. == self.bufferrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#buffer..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().()); |
| 216 | } |
| 217 | |
| 218 | /// This is the immediate case, where we use no buffering |
| 219 | #[inline] |
| 220 | fn step_currentrust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[`GroupInner<K, I, F>`]step_current().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> { |
| 221 | debug_assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.donerust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#done.); |
| 222 | if let elt @ Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(..) = self.current_eltrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#current_elt..takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]take().() { |
| 223 | return elt; |
| 224 | } |
| 225 | match self.next_elementrust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[`GroupInner<K, I, F>`]next_element().() { |
| 226 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 227 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(elt) => { |
| 228 | let key = self.keyrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#key..call_mutrust-analyzer cargo itertools 0.14.0 groupbylazy/KeyFunction#call_mut().(&elt); |
| 229 | match self.current_keyrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#current_key..takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]take().() { |
| 230 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => {} |
| 231 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(old_key) => { |
| 232 | if old_key rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().key { |
| 233 | self.current_keyrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#current_key. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(key); |
| 234 | self.current_eltrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#current_elt. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(elt); |
| 235 | self.top_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#top_group. 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; |
| 236 | return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 237 | } |
| 238 | } |
| 239 | } |
| 240 | self.current_keyrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#current_key. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(key); |
| 241 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(elt) |
| 242 | } |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | /// Request the just started groups' key. |
| 247 | /// |
| 248 | /// `client`: Index of group |
| 249 | /// |
| 250 | /// **Panics** if no group key is available. |
| 251 | fn group_keyrust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[`GroupInner<K, I, F>`]group_key().(&mut self, client: usize) -> K { |
| 252 | // This can only be called after we have just returned the first |
| 253 | // element of a group. |
| 254 | // Perform this by simply buffering one more element, grabbing the |
| 255 | // next key. |
| 256 | debug_assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.donerust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#done.); |
| 257 | debug_assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert!!(client == self.top_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#top_group.); |
| 258 | debug_assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert!!(self.current_keyrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#current_key..is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().()); |
| 259 | debug_assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert!!(self.current_eltrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#current_elt..is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().()); |
| 260 | let old_key = self.current_keyrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#current_key..takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]take().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 261 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(elt) = self.next_elementrust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[`GroupInner<K, I, F>`]next_element().() { |
| 262 | let key = self.keyrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#key..call_mutrust-analyzer cargo itertools 0.14.0 groupbylazy/KeyFunction#call_mut().(&elt); |
| 263 | if old_key rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().key { |
| 264 | self.top_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#top_group. 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; |
| 265 | } |
| 266 | self.current_keyrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#current_key. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(key); |
| 267 | self.current_eltrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#current_elt. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(elt); |
| 268 | } |
| 269 | old_key |
| 270 | } |
| 271 | } |
| 272 | |
| 273 | impl<K, I, F> GroupInnerrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#<K, I, F> |
| 274 | where |
| 275 | I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#, |
| 276 | { |
| 277 | /// Called when a group is dropped |
| 278 | fn drop_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[`GroupInner<K, I, F>`]drop_group().(&mut self, client: usize) { |
| 279 | // It's only useful to track the maximal index |
| 280 | if self.dropped_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#dropped_group. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][Not]not().0 || client 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().self.dropped_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#dropped_group. { |
| 281 | self.dropped_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#dropped_group. = client; |
| 282 | } |
| 283 | } |
| 284 | } |
| 285 | |
| 286 | #[deprecated(note = "Use `ChunkBy` instead", since = "0.13.0")] |
| 287 | /// See [`ChunkBy`](crate::structs::ChunkBy). |
| 288 | pub type GroupByrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupBy#<K, I, F> = ChunkByrust-analyzer cargo itertools 0.14.0 groupbylazy/ChunkBy#<K, I, F>; |
| 289 | |
| 290 | /// `ChunkBy` is the storage for the lazy grouping operation. |
| 291 | /// |
| 292 | /// If the groups are consumed in their original order, or if each |
| 293 | /// group is dropped without keeping it around, then `ChunkBy` uses |
| 294 | /// no allocations. It needs allocations only if several group iterators |
| 295 | /// are alive at the same time. |
| 296 | /// |
| 297 | /// This type implements [`IntoIterator`] (it is **not** an iterator |
| 298 | /// itself), because the group iterators need to borrow from this |
| 299 | /// value. It should be stored in a local variable or temporary and |
| 300 | /// iterated. |
| 301 | /// |
| 302 | /// See [`.chunk_by()`](crate::Itertools::chunk_by) for more information. |
| 303 | #[must_use = "iterator adaptors are lazy and do nothing unless consumed"] |
| 304 | pub struct ChunkByrust-analyzer cargo itertools 0.14.0 groupbylazy/ChunkBy#<K, I, F> |
| 305 | where |
| 306 | I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#, |
| 307 | { |
| 308 | innerrust-analyzer cargo itertools 0.14.0 groupbylazy/ChunkBy#inner.: RefCellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/RefCell#<GroupInnerrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#<K, I, F>>, |
| 309 | // the group iterator's current index. Keep this in the main value |
| 310 | // so that simultaneous iterators all use the same state. |
| 311 | indexrust-analyzer cargo itertools 0.14.0 groupbylazy/ChunkBy#index.: Cellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/Cell#<usize>, |
| 312 | } |
| 313 | |
| 314 | /// Create a new |
| 315 | pub fn newrust-analyzer cargo itertools 0.14.0 groupbylazy/new().<K, J, F>(iter: J, f: F) -> ChunkByrust-analyzer cargo itertools 0.14.0 groupbylazy/ChunkBy#<K, J::IntoIterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#IntoIter#, F> |
| 316 | where |
| 317 | J: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#, |
| 318 | F: FnMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnMut#(&J::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item#) -> K, |
| 319 | { |
| 320 | ChunkByrust-analyzer cargo itertools 0.14.0 groupbylazy/ChunkBy# { |
| 321 | innerrust-analyzer cargo itertools 0.14.0 groupbylazy/ChunkBy#inner.: RefCellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/RefCell#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]new().(GroupInnerrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner# { |
| 322 | keyrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#key.: f, |
| 323 | iterrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#iter.: iter.into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#into_iter().(), |
| 324 | current_keyrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#current_key.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 325 | current_eltrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#current_elt.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 326 | donerust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#done.: false, |
| 327 | top_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#top_group.: 0, |
| 328 | oldest_buffered_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#oldest_buffered_group.: 0, |
| 329 | bottom_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#bottom_group.: 0, |
| 330 | bufferrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#buffer.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(), |
| 331 | dropped_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#dropped_group.: !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][Not]not().0, |
| 332 | }), |
| 333 | indexrust-analyzer cargo itertools 0.14.0 groupbylazy/ChunkBy#index.: Cellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/Cell#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`Cell<T>`]new().(0), |
| 334 | } |
| 335 | } |
| 336 | |
| 337 | impl<K, I, F> ChunkByrust-analyzer cargo itertools 0.14.0 groupbylazy/ChunkBy#<K, I, F> |
| 338 | where |
| 339 | I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#, |
| 340 | { |
| 341 | /// `client`: Index of group that requests next element |
| 342 | fn steprust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[`ChunkBy<K, I, F>`]step().(&self, client: usize) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> |
| 343 | where |
| 344 | 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#) -> K, |
| 345 | K: PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#, |
| 346 | { |
| 347 | self.innerrust-analyzer cargo itertools 0.14.0 groupbylazy/ChunkBy#inner..borrow_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow_mut().().steprust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[`GroupInner<K, I, F>`]step().(client) |
| 348 | } |
| 349 | |
| 350 | /// `client`: Index of group |
| 351 | fn drop_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[`ChunkBy<K, I, F>`]drop_group().(&self, client: usize) { |
| 352 | self.innerrust-analyzer cargo itertools 0.14.0 groupbylazy/ChunkBy#inner..borrow_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow_mut().().drop_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[`GroupInner<K, I, F>`]drop_group().(client); |
| 353 | } |
| 354 | } |
| 355 | |
| 356 | impl<'a, K, I, F> IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator# for &'a ChunkByrust-analyzer cargo itertools 0.14.0 groupbylazy/ChunkBy#<K, I, F> |
| 357 | where |
| 358 | I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#, |
| 359 | I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#: 'a, |
| 360 | 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#) -> K, |
| 361 | K: PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#, |
| 362 | { |
| 363 | type Itemrust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[`&'a ChunkBy<K, I, F>`][IntoIterator]Item# = (K, Grouprust-analyzer cargo itertools 0.14.0 groupbylazy/Group#<'a, K, I, F>); |
| 364 | type IntoIterrust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[`&'a ChunkBy<K, I, F>`][IntoIterator]IntoIter# = Groupsrust-analyzer cargo itertools 0.14.0 groupbylazy/Groups#<'a, K, I, F>; |
| 365 | |
| 366 | fn into_iterrust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[`&'a ChunkBy<K, I, F>`][IntoIterator]into_iter().(self) -> Selfrust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[`&'a ChunkBy<K, I, F>`][IntoIterator]::IntoIterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#IntoIter# { |
| 367 | Groupsrust-analyzer cargo itertools 0.14.0 groupbylazy/Groups# { parentrust-analyzer cargo itertools 0.14.0 groupbylazy/Groups#parent.: self } |
| 368 | } |
| 369 | } |
| 370 | |
| 371 | /// An iterator that yields the Group iterators. |
| 372 | /// |
| 373 | /// Iterator element type is `(K, Group)`: |
| 374 | /// the group's key `K` and the group's iterator. |
| 375 | /// |
| 376 | /// See [`.chunk_by()`](crate::Itertools::chunk_by) for more information. |
| 377 | #[must_use = "iterator adaptors are lazy and do nothing unless consumed"] |
| 378 | pub struct Groupsrust-analyzer cargo itertools 0.14.0 groupbylazy/Groups#<'a, K, I, F> |
| 379 | where |
| 380 | I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# + 'a, |
| 381 | I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#: 'a, |
| 382 | K: 'a, |
| 383 | F: 'a, |
| 384 | { |
| 385 | parentrust-analyzer cargo itertools 0.14.0 groupbylazy/Groups#parent.: &'a ChunkByrust-analyzer cargo itertools 0.14.0 groupbylazy/ChunkBy#<K, I, F>, |
| 386 | } |
| 387 | |
| 388 | impl<'a, K, I, F> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for Groupsrust-analyzer cargo itertools 0.14.0 groupbylazy/Groups#<'a, K, I, F> |
| 389 | where |
| 390 | I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#, |
| 391 | I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#: 'a, |
| 392 | 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#) -> K, |
| 393 | K: PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#, |
| 394 | { |
| 395 | type Itemrust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[`Groups<'a, K, I, F>`][Iterator]Item# = (K, Grouprust-analyzer cargo itertools 0.14.0 groupbylazy/Group#<'a, K, I, F>); |
| 396 | |
| 397 | #[inline] |
| 398 | fn nextrust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[`Groups<'a, K, I, 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 groupbylazy/impl#[`Groups<'a, K, I, F>`][Iterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> { |
| 399 | let index = self.parentrust-analyzer cargo itertools 0.14.0 groupbylazy/Groups#parent..indexrust-analyzer cargo itertools 0.14.0 groupbylazy/ChunkBy#index..getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`Cell<T>`]get().(); |
| 400 | self.parentrust-analyzer cargo itertools 0.14.0 groupbylazy/Groups#parent..indexrust-analyzer cargo itertools 0.14.0 groupbylazy/ChunkBy#index..setrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`Cell<T>`]set().(index 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().1); |
| 401 | let inner = &mut *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefMut<'_, T>`][DerefMut]deref_mut().self.parentrust-analyzer cargo itertools 0.14.0 groupbylazy/Groups#parent..innerrust-analyzer cargo itertools 0.14.0 groupbylazy/ChunkBy#inner..borrow_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow_mut().(); |
| 402 | inner.steprust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[`GroupInner<K, I, F>`]step().(index).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|elt| { |
| 403 | let key = inner.group_keyrust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[`GroupInner<K, I, F>`]group_key().(index); |
| 404 | ( |
| 405 | key, |
| 406 | Grouprust-analyzer cargo itertools 0.14.0 groupbylazy/Group# { |
| 407 | parentrust-analyzer cargo itertools 0.14.0 groupbylazy/Group#parent.: self.parentrust-analyzer cargo itertools 0.14.0 groupbylazy/Groups#parent., |
| 408 | indexrust-analyzer cargo itertools 0.14.0 groupbylazy/Group#index., |
| 409 | firstrust-analyzer cargo itertools 0.14.0 groupbylazy/Group#first.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(elt), |
| 410 | }, |
| 411 | ) |
| 412 | }) |
| 413 | } |
| 414 | } |
| 415 | |
| 416 | /// An iterator for the elements in a single group. |
| 417 | /// |
| 418 | /// Iterator element type is `I::Item`. |
| 419 | pub struct Grouprust-analyzer cargo itertools 0.14.0 groupbylazy/Group#<'a, K, I, F> |
| 420 | where |
| 421 | I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# + 'a, |
| 422 | I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#: 'a, |
| 423 | K: 'a, |
| 424 | F: 'a, |
| 425 | { |
| 426 | parentrust-analyzer cargo itertools 0.14.0 groupbylazy/Group#parent.: &'a ChunkByrust-analyzer cargo itertools 0.14.0 groupbylazy/ChunkBy#<K, I, F>, |
| 427 | indexrust-analyzer cargo itertools 0.14.0 groupbylazy/Group#index.: usize, |
| 428 | firstrust-analyzer cargo itertools 0.14.0 groupbylazy/Group#first.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#>, |
| 429 | } |
| 430 | |
| 431 | impl<'a, K, I, F> Droprust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/drop/Drop# for Grouprust-analyzer cargo itertools 0.14.0 groupbylazy/Group#<'a, K, I, F> |
| 432 | where |
| 433 | I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#, |
| 434 | I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#: 'a, |
| 435 | { |
| 436 | fn droprust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[`Group<'a, K, I, F>`][Drop]drop().(&mut self) { |
| 437 | self.parentrust-analyzer cargo itertools 0.14.0 groupbylazy/Group#parent..drop_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[`ChunkBy<K, I, F>`]drop_group().(self.indexrust-analyzer cargo itertools 0.14.0 groupbylazy/Group#index.); |
| 438 | } |
| 439 | } |
| 440 | |
| 441 | impl<'a, K, I, F> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for Grouprust-analyzer cargo itertools 0.14.0 groupbylazy/Group#<'a, K, I, F> |
| 442 | where |
| 443 | I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#, |
| 444 | I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#: 'a, |
| 445 | 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#) -> K, |
| 446 | K: PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#, |
| 447 | { |
| 448 | type Itemrust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[`Group<'a, K, I, F>`][Iterator]Item# = I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#; |
| 449 | #[inline] |
| 450 | fn nextrust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[`Group<'a, K, I, 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 groupbylazy/impl#[`Group<'a, K, I, F>`][Iterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> { |
| 451 | if let elt @ Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(..) = self.firstrust-analyzer cargo itertools 0.14.0 groupbylazy/Group#first..takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]take().() { |
| 452 | return elt; |
| 453 | } |
| 454 | self.parentrust-analyzer cargo itertools 0.14.0 groupbylazy/Group#parent..steprust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[`ChunkBy<K, I, F>`]step().(self.indexrust-analyzer cargo itertools 0.14.0 groupbylazy/Group#index.) |
| 455 | } |
| 456 | } |
| 457 | |
| 458 | ///// IntoChunks ///// |
| 459 | |
| 460 | /// Create a new |
| 461 | pub fn new_chunksrust-analyzer cargo itertools 0.14.0 groupbylazy/new_chunks().<J>(iter: J, size: usize) -> IntoChunksrust-analyzer cargo itertools 0.14.0 groupbylazy/IntoChunks#<J::IntoIterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#IntoIter#> |
| 462 | where |
| 463 | J: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#, |
| 464 | { |
| 465 | IntoChunksrust-analyzer cargo itertools 0.14.0 groupbylazy/IntoChunks# { |
| 466 | innerrust-analyzer cargo itertools 0.14.0 groupbylazy/IntoChunks#inner.: RefCellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/RefCell#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]new().(GroupInnerrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner# { |
| 467 | keyrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#key.: ChunkIndexrust-analyzer cargo itertools 0.14.0 groupbylazy/ChunkIndex#::newrust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[ChunkIndex]new().(size), |
| 468 | iterrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#iter.: iter.into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#into_iter().(), |
| 469 | current_keyrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#current_key.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 470 | current_eltrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#current_elt.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 471 | donerust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#done.: false, |
| 472 | top_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#top_group.: 0, |
| 473 | oldest_buffered_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#oldest_buffered_group.: 0, |
| 474 | bottom_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#bottom_group.: 0, |
| 475 | bufferrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#buffer.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(), |
| 476 | dropped_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#dropped_group.: !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][Not]not().0, |
| 477 | }), |
| 478 | indexrust-analyzer cargo itertools 0.14.0 groupbylazy/IntoChunks#index.: Cellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/Cell#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`Cell<T>`]new().(0), |
| 479 | } |
| 480 | } |
| 481 | |
| 482 | /// `ChunkLazy` is the storage for a lazy chunking operation. |
| 483 | /// |
| 484 | /// `IntoChunks` behaves just like `ChunkBy`: it is iterable, and |
| 485 | /// it only buffers if several chunk iterators are alive at the same time. |
| 486 | /// |
| 487 | /// This type implements [`IntoIterator`] (it is **not** an iterator |
| 488 | /// itself), because the chunk iterators need to borrow from this |
| 489 | /// value. It should be stored in a local variable or temporary and |
| 490 | /// iterated. |
| 491 | /// |
| 492 | /// Iterator element type is `Chunk`, each chunk's iterator. |
| 493 | /// |
| 494 | /// See [`.chunks()`](crate::Itertools::chunks) for more information. |
| 495 | #[must_use = "iterator adaptors are lazy and do nothing unless consumed"] |
| 496 | pub struct IntoChunksrust-analyzer cargo itertools 0.14.0 groupbylazy/IntoChunks#<I> |
| 497 | where |
| 498 | I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#, |
| 499 | { |
| 500 | innerrust-analyzer cargo itertools 0.14.0 groupbylazy/IntoChunks#inner.: RefCellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/RefCell#<GroupInnerrust-analyzer cargo itertools 0.14.0 groupbylazy/GroupInner#<usize, I, ChunkIndexrust-analyzer cargo itertools 0.14.0 groupbylazy/ChunkIndex#>>, |
| 501 | // the chunk iterator's current index. Keep this in the main value |
| 502 | // so that simultaneous iterators all use the same state. |
| 503 | indexrust-analyzer cargo itertools 0.14.0 groupbylazy/IntoChunks#index.: Cellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/Cell#<usize>, |
| 504 | } |
| 505 | |
| 506 | impl<I> Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# for IntoChunksrust-analyzer cargo itertools 0.14.0 groupbylazy/IntoChunks#<I> |
| 507 | where |
| 508 | I: Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# + Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#, |
| 509 | I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#: Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#, |
| 510 | { |
| 511 | clone_fieldsrust-analyzer cargo itertools 0.14.0 impl_macros/clone_fields!!(innerrust-analyzer cargo itertools 0.14.0 groupbylazy/IntoChunks#inner., indexrust-analyzer cargo itertools 0.14.0 groupbylazy/IntoChunks#index.); |
| 512 | } |
| 513 | |
| 514 | impl<I> IntoChunksrust-analyzer cargo itertools 0.14.0 groupbylazy/IntoChunks#<I> |
| 515 | where |
| 516 | I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#, |
| 517 | { |
| 518 | /// `client`: Index of chunk that requests next element |
| 519 | fn steprust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[`IntoChunks<I>`]step().(&self, client: usize) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> { |
| 520 | self.innerrust-analyzer cargo itertools 0.14.0 groupbylazy/IntoChunks#inner..borrow_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow_mut().().steprust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[`GroupInner<K, I, F>`]step().(client) |
| 521 | } |
| 522 | |
| 523 | /// `client`: Index of chunk |
| 524 | fn drop_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[`IntoChunks<I>`]drop_group().(&self, client: usize) { |
| 525 | self.innerrust-analyzer cargo itertools 0.14.0 groupbylazy/IntoChunks#inner..borrow_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow_mut().().drop_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[`GroupInner<K, I, F>`]drop_group().(client); |
| 526 | } |
| 527 | } |
| 528 | |
| 529 | impl<'a, I> IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator# for &'a IntoChunksrust-analyzer cargo itertools 0.14.0 groupbylazy/IntoChunks#<I> |
| 530 | where |
| 531 | I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#, |
| 532 | I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#: 'a, |
| 533 | { |
| 534 | type Itemrust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[`&'a IntoChunks<I>`][IntoIterator]Item# = Chunkrust-analyzer cargo itertools 0.14.0 groupbylazy/Chunk#<'a, I>; |
| 535 | type IntoIterrust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[`&'a IntoChunks<I>`][IntoIterator]IntoIter# = Chunksrust-analyzer cargo itertools 0.14.0 groupbylazy/Chunks#<'a, I>; |
| 536 | |
| 537 | fn into_iterrust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[`&'a IntoChunks<I>`][IntoIterator]into_iter().(self) -> Selfrust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[`&'a IntoChunks<I>`][IntoIterator]::IntoIterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#IntoIter# { |
| 538 | Chunksrust-analyzer cargo itertools 0.14.0 groupbylazy/Chunks# { parentrust-analyzer cargo itertools 0.14.0 groupbylazy/Chunks#parent.: self } |
| 539 | } |
| 540 | } |
| 541 | |
| 542 | /// An iterator that yields the Chunk iterators. |
| 543 | /// |
| 544 | /// Iterator element type is `Chunk`. |
| 545 | /// |
| 546 | /// See [`.chunks()`](crate::Itertools::chunks) for more information. |
| 547 | #[must_use = "iterator adaptors are lazy and do nothing unless consumed"] |
| 548 | #[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:)] |
| 549 | pub struct Chunksrust-analyzer cargo itertools 0.14.0 groupbylazy/Chunks#<'a, I> |
| 550 | where |
| 551 | I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# + 'a, |
| 552 | I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#: 'a, |
| 553 | { |
| 554 | parentrust-analyzer cargo itertools 0.14.0 groupbylazy/Chunks#parent.: &'a IntoChunksrust-analyzer cargo itertools 0.14.0 groupbylazy/IntoChunks#<I>, |
| 555 | } |
| 556 | |
| 557 | impl<'a, I> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for Chunksrust-analyzer cargo itertools 0.14.0 groupbylazy/Chunks#<'a, I> |
| 558 | where |
| 559 | I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#, |
| 560 | I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#: 'a, |
| 561 | { |
| 562 | type Itemrust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[`Chunks<'a, I>`][Iterator]Item# = Chunkrust-analyzer cargo itertools 0.14.0 groupbylazy/Chunk#<'a, I>; |
| 563 | |
| 564 | #[inline] |
| 565 | fn nextrust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[`Chunks<'a, 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 groupbylazy/impl#[`Chunks<'a, I>`][Iterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> { |
| 566 | let index = self.parentrust-analyzer cargo itertools 0.14.0 groupbylazy/Chunks#parent..indexrust-analyzer cargo itertools 0.14.0 groupbylazy/IntoChunks#index..getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`Cell<T>`]get().(); |
| 567 | self.parentrust-analyzer cargo itertools 0.14.0 groupbylazy/Chunks#parent..indexrust-analyzer cargo itertools 0.14.0 groupbylazy/IntoChunks#index..setrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`Cell<T>`]set().(index 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().1); |
| 568 | let inner = &mut *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefMut<'_, T>`][DerefMut]deref_mut().self.parentrust-analyzer cargo itertools 0.14.0 groupbylazy/Chunks#parent..innerrust-analyzer cargo itertools 0.14.0 groupbylazy/IntoChunks#inner..borrow_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow_mut().(); |
| 569 | inner.steprust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[`GroupInner<K, I, F>`]step().(index).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|elt| Chunkrust-analyzer cargo itertools 0.14.0 groupbylazy/Chunk# { |
| 570 | parentrust-analyzer cargo itertools 0.14.0 groupbylazy/Chunk#parent.: self.parentrust-analyzer cargo itertools 0.14.0 groupbylazy/Chunks#parent., |
| 571 | indexrust-analyzer cargo itertools 0.14.0 groupbylazy/Chunk#index., |
| 572 | firstrust-analyzer cargo itertools 0.14.0 groupbylazy/Chunk#first.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(elt), |
| 573 | }) |
| 574 | } |
| 575 | } |
| 576 | |
| 577 | /// An iterator for the elements in a single chunk. |
| 578 | /// |
| 579 | /// Iterator element type is `I::Item`. |
| 580 | pub struct Chunkrust-analyzer cargo itertools 0.14.0 groupbylazy/Chunk#<'a, I> |
| 581 | where |
| 582 | I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# + 'a, |
| 583 | I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#: 'a, |
| 584 | { |
| 585 | parentrust-analyzer cargo itertools 0.14.0 groupbylazy/Chunk#parent.: &'a IntoChunksrust-analyzer cargo itertools 0.14.0 groupbylazy/IntoChunks#<I>, |
| 586 | indexrust-analyzer cargo itertools 0.14.0 groupbylazy/Chunk#index.: usize, |
| 587 | firstrust-analyzer cargo itertools 0.14.0 groupbylazy/Chunk#first.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#>, |
| 588 | } |
| 589 | |
| 590 | impl<'a, I> Droprust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/drop/Drop# for Chunkrust-analyzer cargo itertools 0.14.0 groupbylazy/Chunk#<'a, I> |
| 591 | where |
| 592 | I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#, |
| 593 | I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#: 'a, |
| 594 | { |
| 595 | fn droprust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[`Chunk<'a, I>`][Drop]drop().(&mut self) { |
| 596 | self.parentrust-analyzer cargo itertools 0.14.0 groupbylazy/Chunk#parent..drop_grouprust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[`IntoChunks<I>`]drop_group().(self.indexrust-analyzer cargo itertools 0.14.0 groupbylazy/Chunk#index.); |
| 597 | } |
| 598 | } |
| 599 | |
| 600 | impl<'a, I> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for Chunkrust-analyzer cargo itertools 0.14.0 groupbylazy/Chunk#<'a, I> |
| 601 | where |
| 602 | I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#, |
| 603 | I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#: 'a, |
| 604 | { |
| 605 | type Itemrust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[`Chunk<'a, I>`][Iterator]Item# = I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#; |
| 606 | #[inline] |
| 607 | fn nextrust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[`Chunk<'a, 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 groupbylazy/impl#[`Chunk<'a, I>`][Iterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> { |
| 608 | if let elt @ Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(..) = self.firstrust-analyzer cargo itertools 0.14.0 groupbylazy/Chunk#first..takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]take().() { |
| 609 | return elt; |
| 610 | } |
| 611 | self.parentrust-analyzer cargo itertools 0.14.0 groupbylazy/Chunk#parent..steprust-analyzer cargo itertools 0.14.0 groupbylazy/impl#[`IntoChunks<I>`]step().(self.indexrust-analyzer cargo itertools 0.14.0 groupbylazy/Chunk#index.) |
| 612 | } |
| 613 | } |