| 1 | // Copyright (c) 2018 the linkerd2-proxy authors |
| 2 | // Copyright (c) The buf-list Contributors |
| 3 | // SPDX-License-Identifier: Apache-2.0 |
| 4 | |
| 5 | use bytesrust-analyzer cargo bytes 1.3.0 crate/::{Bufrust-analyzer cargo bytes 1.3.0 buf/buf_impl/Buf#, BufMutrust-analyzer cargo bytes 1.3.0 buf/buf_mut/BufMut#, Bytesrust-analyzer cargo bytes 1.3.0 bytes/Bytes#, BytesMutrust-analyzer cargo bytes 1.3.0 bytes_mut/BytesMut#}; |
| 6 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::{ |
| 7 | collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::VecDequerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/VecDeque#, |
| 8 | iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::IoSlicerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/IoSlice#, |
| 9 | iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::{FromIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/FromIterator#, FusedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/marker/FusedIterator#}, |
| 10 | syncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/::OnceLockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/OnceLock#, |
| 11 | }; |
| 12 | |
| 13 | /// Data composed of a list of [`Bytes`] chunks. |
| 14 | /// |
| 15 | /// For more, see the [crate documentation](crate). |
| 16 | #[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:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:)] |
| 17 | pub struct BufListrust-analyzer cargo buf-list 1.1.2 imp/BufList# { |
| 18 | // Invariant: none of the bufs in this queue are zero-length. |
| 19 | bufsrust-analyzer cargo buf-list 1.1.2 imp/BufList#bufs.: VecDequerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/VecDeque#<Bytesrust-analyzer cargo bytes 1.3.0 bytes/Bytes#>, |
| 20 | |
| 21 | /// An index of chunks and their start positions. There's an additional index at the end, which |
| 22 | /// is the length of the list (list.num_bytes()). |
| 23 | start_posrust-analyzer cargo buf-list 1.1.2 imp/BufList#start_pos.: OnceLockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/OnceLock#<Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<[u64]>>, |
| 24 | } |
| 25 | |
| 26 | impl BufListrust-analyzer cargo buf-list 1.1.2 imp/BufList# { |
| 27 | /// Creates a new, empty, `BufList`. |
| 28 | #[inline] |
| 29 | pub fn newrust-analyzer cargo buf-list 1.1.2 imp/impl#[BufList]new().() -> Selfrust-analyzer cargo buf-list 1.1.2 imp/impl#[BufList] { |
| 30 | Selfrust-analyzer cargo buf-list 1.1.2 imp/impl#[BufList]::defaultrust-analyzer cargo buf-list 1.1.2 imp/impl#[BufList][Default]default().() |
| 31 | } |
| 32 | |
| 33 | #[inline] |
| 34 | pub(craterust-analyzer cargo buf-list 1.1.2 crate/) fn get_start_posrust-analyzer cargo buf-list 1.1.2 imp/impl#[BufList]get_start_pos().(&self) -> &[u64] { |
| 35 | self.start_posrust-analyzer cargo buf-list 1.1.2 imp/BufList#start_pos..get_or_initrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/impl#[`OnceLock<T>`]get_or_init().(|| { |
| 36 | let mut start_pos = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]with_capacity().(self.bufsrust-analyzer cargo buf-list 1.1.2 imp/BufList#bufs..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]len().() 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); |
| 37 | let mut next = 0u64; |
| 38 | for chunk in self.bufsrust-analyzer cargo buf-list 1.1.2 imp/BufList#bufs..iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]iter().() { |
| 39 | start_pos.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(next); |
| 40 | next rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`AddAssign<Self>`]add_assign().chunk.lenrust-analyzer cargo bytes 1.3.0 bytes/impl#[Bytes]len().() as u64; |
| 41 | } |
| 42 | // Add the length of the chunk at the end. |
| 43 | start_pos.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(next); |
| 44 | start_pos.into_boxed_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]into_boxed_slice().() |
| 45 | }) |
| 46 | } |
| 47 | |
| 48 | /// Creates a new, empty, `BufList` with the given capacity. |
| 49 | #[inline] |
| 50 | pub fn with_capacityrust-analyzer cargo buf-list 1.1.2 imp/impl#[BufList]with_capacity().(capacity: usize) -> Selfrust-analyzer cargo buf-list 1.1.2 imp/impl#[BufList] { |
| 51 | Selfrust-analyzer cargo buf-list 1.1.2 imp/impl#[BufList] { |
| 52 | bufsrust-analyzer cargo buf-list 1.1.2 imp/BufList#bufs.: VecDequerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/VecDeque#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T>`]with_capacity().(capacity), |
| 53 | start_posrust-analyzer cargo buf-list 1.1.2 imp/BufList#start_pos.: OnceLockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/OnceLock#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/impl#[`OnceLock<T>`]new().(), |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | /// Returns the total number of chunks in this `BufList`. |
| 58 | /// |
| 59 | /// # Examples |
| 60 | /// |
| 61 | /// ``` |
| 62 | /// use buf_list::BufList; |
| 63 | /// |
| 64 | /// let buf_list = vec![&b"hello"[..], &b"world"[..]].into_iter().collect::<BufList>(); |
| 65 | /// assert_eq!(buf_list.num_chunks(), 2); |
| 66 | /// ``` |
| 67 | #[inline] |
| 68 | pub fn num_chunksrust-analyzer cargo buf-list 1.1.2 imp/impl#[BufList]num_chunks().(&self) -> usize { |
| 69 | self.bufsrust-analyzer cargo buf-list 1.1.2 imp/BufList#bufs..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]len().() |
| 70 | } |
| 71 | |
| 72 | /// Returns the total number of bytes across all chunks. |
| 73 | /// |
| 74 | /// # Examples |
| 75 | /// |
| 76 | /// ``` |
| 77 | /// use buf_list::BufList; |
| 78 | /// |
| 79 | /// let buf_list = vec![&b"hello"[..], &b"world"[..]].into_iter().collect::<BufList>(); |
| 80 | /// assert_eq!(buf_list.num_bytes(), 10); |
| 81 | /// ``` |
| 82 | #[inline] |
| 83 | pub fn num_bytesrust-analyzer cargo buf-list 1.1.2 imp/impl#[BufList]num_bytes().(&self) -> usize { |
| 84 | self.remainingrust-analyzer cargo buf-list 1.1.2 imp/impl#[BufList][Buf]remaining().() |
| 85 | } |
| 86 | |
| 87 | /// Provides a reference to the chunk at the given index. |
| 88 | /// |
| 89 | /// # Examples |
| 90 | /// |
| 91 | /// ``` |
| 92 | /// use buf_list::BufList; |
| 93 | /// use bytes::Bytes; |
| 94 | /// |
| 95 | /// let buf_list = vec![&b"hello"[..], &b"world"[..]].into_iter().collect::<BufList>(); |
| 96 | /// assert_eq!(buf_list.get_chunk(1), Some(&Bytes::from(&b"world"[..]))); |
| 97 | /// ``` |
| 98 | #[inline] |
| 99 | pub fn get_chunkrust-analyzer cargo buf-list 1.1.2 imp/impl#[BufList]get_chunk().(&self, index: usize) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&Bytesrust-analyzer cargo bytes 1.3.0 bytes/Bytes#> { |
| 100 | self.bufsrust-analyzer cargo buf-list 1.1.2 imp/BufList#bufs..getrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]get().(index) |
| 101 | } |
| 102 | |
| 103 | /// Iterates over the chunks in this list. |
| 104 | #[inline] |
| 105 | pub fn iterrust-analyzer cargo buf-list 1.1.2 imp/impl#[BufList]iter().(&self) -> Iterrust-analyzer cargo buf-list 1.1.2 imp/Iter#<'_> { |
| 106 | Iterrust-analyzer cargo buf-list 1.1.2 imp/Iter# { |
| 107 | iterrust-analyzer cargo buf-list 1.1.2 imp/Iter#iter.: self.bufsrust-analyzer cargo buf-list 1.1.2 imp/BufList#bufs..iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]iter().(), |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | /// Adds a new chunk to this list. |
| 112 | /// |
| 113 | /// If the provided [`Buf`] is zero-length, it will not be added to the list. |
| 114 | /// |
| 115 | /// # Examples |
| 116 | /// |
| 117 | /// ``` |
| 118 | /// use buf_list::BufList; |
| 119 | /// use bytes::{Buf, Bytes}; |
| 120 | /// |
| 121 | /// let mut buf_list = BufList::new(); |
| 122 | /// |
| 123 | /// // &'static [u8] implements Buf. |
| 124 | /// buf_list.push_chunk(&b"hello"[..]); |
| 125 | /// assert_eq!(buf_list.chunk(), &b"hello"[..]); |
| 126 | /// |
| 127 | /// // Bytes also implements Buf. |
| 128 | /// buf_list.push_chunk(Bytes::from_static(&b"world"[..])); |
| 129 | /// assert_eq!(buf_list.num_chunks(), 2); |
| 130 | /// |
| 131 | /// // A zero-length `Buf` will not be added to the list. |
| 132 | /// buf_list.push_chunk(Bytes::new()); |
| 133 | /// assert_eq!(buf_list.num_chunks(), 2); |
| 134 | /// ``` |
| 135 | pub fn push_chunkrust-analyzer cargo buf-list 1.1.2 imp/impl#[BufList]push_chunk().<B: Bufrust-analyzer cargo bytes 1.3.0 buf/buf_impl/Buf#>(&mut self, mut data: B) -> Bytesrust-analyzer cargo bytes 1.3.0 bytes/Bytes# { |
| 136 | // mutable borrow acquired, invalidate the OnceLock |
| 137 | self.start_posrust-analyzer cargo buf-list 1.1.2 imp/BufList#start_pos. = OnceLockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/OnceLock#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/impl#[`OnceLock<T>`]new().(); |
| 138 | |
| 139 | let len = data.remainingrust-analyzer cargo bytes 1.3.0 buf/buf_impl/Buf#remaining().(); |
| 140 | // `data` is (almost) certainly a `Bytes`, so `copy_to_bytes` should |
| 141 | // internally be a cheap refcount bump almost all of the time. |
| 142 | // But, if it isn't, this will copy it to a `Bytes` that we can |
| 143 | // now clone. |
| 144 | let bytes = data.copy_to_bytesrust-analyzer cargo bytes 1.3.0 buf/buf_impl/Buf#copy_to_bytes().(len); |
| 145 | |
| 146 | // Buffer a clone. Don't push zero-length bufs to uphold the invariant. |
| 147 | if 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().0 { |
| 148 | self.bufsrust-analyzer cargo buf-list 1.1.2 imp/BufList#bufs..push_backrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]push_back().(bytes.clonerust-analyzer cargo bytes 1.3.0 bytes/impl#[Bytes][Clone]clone().()); |
| 149 | } |
| 150 | |
| 151 | // Return the bytes |
| 152 | bytes |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | impl<B: Bufrust-analyzer cargo bytes 1.3.0 buf/buf_impl/Buf#> Extendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/Extend#<B> for BufListrust-analyzer cargo buf-list 1.1.2 imp/BufList# { |
| 157 | fn extendrust-analyzer cargo buf-list 1.1.2 imp/impl#[BufList][`Extend<B>`]extend().<T: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = B>>(&mut self, iter: T) { |
| 158 | // mutable borrow acquired, invalidate the OnceLock |
| 159 | self.start_posrust-analyzer cargo buf-list 1.1.2 imp/BufList#start_pos. = OnceLockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/OnceLock#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/impl#[`OnceLock<T>`]new().(); |
| 160 | |
| 161 | for buf in iter.into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#into_iter().() { |
| 162 | self.push_chunkrust-analyzer cargo buf-list 1.1.2 imp/impl#[BufList]push_chunk().(buf); |
| 163 | } |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | impl<B: Bufrust-analyzer cargo bytes 1.3.0 buf/buf_impl/Buf#> FromIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/FromIterator#<B> for BufListrust-analyzer cargo buf-list 1.1.2 imp/BufList# { |
| 168 | fn from_iterrust-analyzer cargo buf-list 1.1.2 imp/impl#[BufList][`FromIterator<B>`]from_iter().<T: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = B>>(iter: T) -> Selfrust-analyzer cargo buf-list 1.1.2 imp/impl#[BufList][`FromIterator<B>`] { |
| 169 | let mut buf_list = BufListrust-analyzer cargo buf-list 1.1.2 imp/BufList#::newrust-analyzer cargo buf-list 1.1.2 imp/impl#[BufList]new().(); |
| 170 | for buf in iter.into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#into_iter().() { |
| 171 | buf_list.push_chunkrust-analyzer cargo buf-list 1.1.2 imp/impl#[BufList]push_chunk().(buf); |
| 172 | } |
| 173 | buf_list |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | impl IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator# for BufListrust-analyzer cargo buf-list 1.1.2 imp/BufList# { |
| 178 | type Itemrust-analyzer cargo buf-list 1.1.2 imp/impl#[BufList][IntoIterator]Item# = Bytesrust-analyzer cargo bytes 1.3.0 bytes/Bytes#; |
| 179 | type IntoIterrust-analyzer cargo buf-list 1.1.2 imp/impl#[BufList][IntoIterator]IntoIter# = IntoIterrust-analyzer cargo buf-list 1.1.2 imp/IntoIter#; |
| 180 | |
| 181 | #[inline] |
| 182 | fn into_iterrust-analyzer cargo buf-list 1.1.2 imp/impl#[BufList][IntoIterator]into_iter().(self) -> Selfrust-analyzer cargo buf-list 1.1.2 imp/impl#[BufList][IntoIterator]::IntoIterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#IntoIter# { |
| 183 | IntoIterrust-analyzer cargo buf-list 1.1.2 imp/IntoIter# { |
| 184 | iterrust-analyzer cargo buf-list 1.1.2 imp/IntoIter#iter.: self.bufsrust-analyzer cargo buf-list 1.1.2 imp/BufList#bufs..into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`][IntoIterator]into_iter().(), |
| 185 | } |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | impl<'a> IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator# for &'a BufListrust-analyzer cargo buf-list 1.1.2 imp/BufList# { |
| 190 | type Itemrust-analyzer cargo buf-list 1.1.2 imp/impl#[`&'a BufList`][IntoIterator]Item# = &'a Bytesrust-analyzer cargo bytes 1.3.0 bytes/Bytes#; |
| 191 | type IntoIterrust-analyzer cargo buf-list 1.1.2 imp/impl#[`&'a BufList`][IntoIterator]IntoIter# = Iterrust-analyzer cargo buf-list 1.1.2 imp/Iter#<'a>; |
| 192 | |
| 193 | #[inline] |
| 194 | fn into_iterrust-analyzer cargo buf-list 1.1.2 imp/impl#[`&'a BufList`][IntoIterator]into_iter().(self) -> Selfrust-analyzer cargo buf-list 1.1.2 imp/impl#[`&'a BufList`][IntoIterator]::IntoIterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#IntoIter# { |
| 195 | self.iterrust-analyzer cargo buf-list 1.1.2 imp/impl#[BufList]iter().() |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | impl AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<BufListrust-analyzer cargo buf-list 1.1.2 imp/BufList#> for BufListrust-analyzer cargo buf-list 1.1.2 imp/BufList# { |
| 200 | fn as_refrust-analyzer cargo buf-list 1.1.2 imp/impl#[BufList][`AsRef<Self>`]as_ref().(&self) -> &BufListrust-analyzer cargo buf-list 1.1.2 imp/BufList# { |
| 201 | self |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | impl Bufrust-analyzer cargo bytes 1.3.0 buf/buf_impl/Buf# for BufListrust-analyzer cargo buf-list 1.1.2 imp/BufList# { |
| 206 | fn remainingrust-analyzer cargo buf-list 1.1.2 imp/impl#[BufList][Buf]remaining().(&self) -> usize { |
| 207 | self.bufsrust-analyzer cargo buf-list 1.1.2 imp/BufList#bufs..iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(Bufrust-analyzer cargo bytes 1.3.0 buf/buf_impl/Buf#::remainingrust-analyzer cargo bytes 1.3.0 bytes/impl#[Bytes][Buf]remaining().).sumrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#sum().() |
| 208 | } |
| 209 | |
| 210 | fn chunkrust-analyzer cargo buf-list 1.1.2 imp/impl#[BufList][Buf]chunk().(&self) -> &[u8] { |
| 211 | self.bufsrust-analyzer cargo buf-list 1.1.2 imp/BufList#bufs..frontrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]front().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(Bufrust-analyzer cargo bytes 1.3.0 buf/buf_impl/Buf#::chunkrust-analyzer cargo bytes 1.3.0 bytes/impl#[Bytes][Buf]chunk().).unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(&[]) |
| 212 | } |
| 213 | |
| 214 | fn chunks_vectoredrust-analyzer cargo buf-list 1.1.2 imp/impl#[BufList][Buf]chunks_vectored().<'iovs>(&'iovs self, iovs: &mut [IoSlicerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/IoSlice#<'iovs>]) -> usize { |
| 215 | // Are there more than zero iovecs to write to? |
| 216 | if iovs.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]is_empty().() { |
| 217 | return 0; |
| 218 | } |
| 219 | |
| 220 | let to_fill = (iovs.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()).minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#min().(self.bufsrust-analyzer cargo buf-list 1.1.2 imp/BufList#bufs..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]len().()); |
| 221 | for (i, iov) in iovs.iter_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter_mut().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().().takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take().(to_fill) { |
| 222 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().iov = IoSlicerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/IoSlice#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/impl#[`IoSlice<'a>`]new().(&self.bufsrust-analyzer cargo buf-list 1.1.2 imp/BufList#bufs.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`][`Index<usize>`]index().i]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`][`Index<usize>`]index().); |
| 223 | } |
| 224 | |
| 225 | to_fill |
| 226 | } |
| 227 | |
| 228 | fn advancerust-analyzer cargo buf-list 1.1.2 imp/impl#[BufList][Buf]advance().(&mut self, mut amt: usize) { |
| 229 | // mutable borrow acquired, invalidate the OnceLock |
| 230 | self.start_posrust-analyzer cargo buf-list 1.1.2 imp/BufList#start_pos. = OnceLockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/OnceLock#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/impl#[`OnceLock<T>`]new().(); |
| 231 | |
| 232 | while amt 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 { |
| 233 | let rem = self.bufsrust-analyzer cargo buf-list 1.1.2 imp/BufList#bufs.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`][`Index<usize>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`][`Index<usize>`]index()..remainingrust-analyzer cargo bytes 1.3.0 bytes/impl#[Bytes][Buf]remaining().(); |
| 234 | // If the amount to advance by is less than the first buffer in |
| 235 | // the buffer list, advance that buffer's cursor by `amt`, |
| 236 | // and we're done. |
| 237 | if rem 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().amt { |
| 238 | self.bufsrust-analyzer cargo buf-list 1.1.2 imp/BufList#bufs.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`][`IndexMut<usize>`]index_mut().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`][`IndexMut<usize>`]index_mut()..advancerust-analyzer cargo bytes 1.3.0 bytes/impl#[Bytes][Buf]advance().(amt); |
| 239 | return; |
| 240 | } |
| 241 | |
| 242 | // Otherwise, advance the first buffer to its end, and |
| 243 | // continue. |
| 244 | self.bufsrust-analyzer cargo buf-list 1.1.2 imp/BufList#bufs.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`][`IndexMut<usize>`]index_mut().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`][`IndexMut<usize>`]index_mut()..advancerust-analyzer cargo bytes 1.3.0 bytes/impl#[Bytes][Buf]advance().(rem); |
| 245 | amt 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().rem; |
| 246 | |
| 247 | self.bufsrust-analyzer cargo buf-list 1.1.2 imp/BufList#bufs..pop_frontrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]pop_front().(); |
| 248 | } |
| 249 | } |
| 250 | |
| 251 | fn copy_to_bytesrust-analyzer cargo buf-list 1.1.2 imp/impl#[BufList][Buf]copy_to_bytes().(&mut self, len: usize) -> Bytesrust-analyzer cargo bytes 1.3.0 bytes/Bytes# { |
| 252 | // mutable borrow acquired, invalidate the OnceLock |
| 253 | self.start_posrust-analyzer cargo buf-list 1.1.2 imp/BufList#start_pos. = OnceLockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/OnceLock#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/impl#[`OnceLock<T>`]new().(); |
| 254 | |
| 255 | // If the length of the requested `Bytes` is <= the length of the front |
| 256 | // buffer, we can just use its `copy_to_bytes` implementation (which is |
| 257 | // just a reference count bump). |
| 258 | match self.bufsrust-analyzer cargo buf-list 1.1.2 imp/BufList#bufs..front_mutrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]front_mut().() { |
| 259 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(first) if len 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().first.remainingrust-analyzer cargo bytes 1.3.0 buf/buf_impl/impl#[`&mut T`][Buf]remaining().() => { |
| 260 | let buf = first.copy_to_bytesrust-analyzer cargo bytes 1.3.0 bytes/impl#[Bytes][Buf]copy_to_bytes().(len); |
| 261 | // If we consumed the first buffer, also advance our "cursor" by |
| 262 | // popping it. |
| 263 | if first.remainingrust-analyzer cargo bytes 1.3.0 buf/buf_impl/impl#[`&mut T`][Buf]remaining().() 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 { |
| 264 | self.bufsrust-analyzer cargo buf-list 1.1.2 imp/BufList#bufs..pop_frontrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]pop_front().(); |
| 265 | } |
| 266 | |
| 267 | buf |
| 268 | } |
| 269 | _ => { |
| 270 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!( |
| 271 | len <= self.remainingrust-analyzer cargo bytes 1.3.0 buf/buf_impl/impl#[`&mut T`][Buf]remaining().(), |
| 272 | "`len` ({}) greater than remaining ({})", |
| 273 | len, |
| 274 | self.remainingrust-analyzer cargo bytes 1.3.0 buf/buf_impl/impl#[`&mut T`][Buf]remaining().() |
| 275 | ); |
| 276 | let mut buf = BytesMutrust-analyzer cargo bytes 1.3.0 bytes_mut/BytesMut#::with_capacityrust-analyzer cargo bytes 1.3.0 bytes_mut/impl#[BytesMut]with_capacity().(len); |
| 277 | buf.putrust-analyzer cargo bytes 1.3.0 bytes_mut/impl#[BytesMut][BufMut]put().(self.takerust-analyzer cargo bytes 1.3.0 buf/buf_impl/Buf#take().(len)); |
| 278 | buf.freezerust-analyzer cargo bytes 1.3.0 bytes_mut/impl#[BytesMut]freeze().() |
| 279 | } |
| 280 | } |
| 281 | } |
| 282 | } |
| 283 | |
| 284 | impl<T: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Bytesrust-analyzer cargo bytes 1.3.0 bytes/Bytes#>> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<T> for BufListrust-analyzer cargo buf-list 1.1.2 imp/BufList# { |
| 285 | fn fromrust-analyzer cargo buf-list 1.1.2 imp/impl#[BufList][`From<T>`]from().(value: T) -> Selfrust-analyzer cargo buf-list 1.1.2 imp/impl#[BufList][`From<T>`] { |
| 286 | let mut buf_list = BufListrust-analyzer cargo buf-list 1.1.2 imp/BufList#::with_capacityrust-analyzer cargo buf-list 1.1.2 imp/impl#[BufList]with_capacity().(1); |
| 287 | buf_list.push_chunkrust-analyzer cargo buf-list 1.1.2 imp/impl#[BufList]push_chunk().(value.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().()); |
| 288 | buf_list |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | /// An owned iterator over chunks in a [`BufList`]. |
| 293 | /// |
| 294 | /// Returned by the [`IntoIterator`] implementation for [`BufList`]. |
| 295 | #[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:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 296 | pub struct IntoIterrust-analyzer cargo buf-list 1.1.2 imp/IntoIter# { |
| 297 | iterrust-analyzer cargo buf-list 1.1.2 imp/IntoIter#iter.: 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/::vec_dequerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/::IntoIterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/into_iter/IntoIter#<Bytesrust-analyzer cargo bytes 1.3.0 bytes/Bytes#>, |
| 298 | } |
| 299 | |
| 300 | impl Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for IntoIterrust-analyzer cargo buf-list 1.1.2 imp/IntoIter# { |
| 301 | type Itemrust-analyzer cargo buf-list 1.1.2 imp/impl#[IntoIter][Iterator]Item# = Bytesrust-analyzer cargo bytes 1.3.0 bytes/Bytes#; |
| 302 | |
| 303 | #[inline] |
| 304 | fn nextrust-analyzer cargo buf-list 1.1.2 imp/impl#[IntoIter][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo buf-list 1.1.2 imp/impl#[IntoIter][Iterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> { |
| 305 | self.iterrust-analyzer cargo buf-list 1.1.2 imp/IntoIter#iter..nextrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/into_iter/impl#[`IntoIter<T, A>`][Iterator]next().() |
| 306 | } |
| 307 | |
| 308 | #[inline] |
| 309 | fn size_hintrust-analyzer cargo buf-list 1.1.2 imp/impl#[IntoIter][Iterator]size_hint().(&self) -> (usize, Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>) { |
| 310 | self.iterrust-analyzer cargo buf-list 1.1.2 imp/IntoIter#iter..size_hintrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/into_iter/impl#[`IntoIter<T, A>`][Iterator]size_hint().() |
| 311 | } |
| 312 | } |
| 313 | |
| 314 | impl DoubleEndedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/double_ended/DoubleEndedIterator# for IntoIterrust-analyzer cargo buf-list 1.1.2 imp/IntoIter# { |
| 315 | #[inline] |
| 316 | fn next_backrust-analyzer cargo buf-list 1.1.2 imp/impl#[IntoIter][DoubleEndedIterator]next_back().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo buf-list 1.1.2 imp/impl#[IntoIter][DoubleEndedIterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> { |
| 317 | self.iterrust-analyzer cargo buf-list 1.1.2 imp/IntoIter#iter..next_backrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/into_iter/impl#[`IntoIter<T, A>`][DoubleEndedIterator]next_back().() |
| 318 | } |
| 319 | } |
| 320 | |
| 321 | impl ExactSizeIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/exact_size/ExactSizeIterator# for IntoIterrust-analyzer cargo buf-list 1.1.2 imp/IntoIter# { |
| 322 | #[inline] |
| 323 | fn lenrust-analyzer cargo buf-list 1.1.2 imp/impl#[IntoIter][ExactSizeIterator]len().(&self) -> usize { |
| 324 | self.iterrust-analyzer cargo buf-list 1.1.2 imp/IntoIter#iter..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/exact_size/ExactSizeIterator#len().() |
| 325 | } |
| 326 | } |
| 327 | |
| 328 | impl FusedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/marker/FusedIterator# for IntoIterrust-analyzer cargo buf-list 1.1.2 imp/IntoIter# {} |
| 329 | |
| 330 | /// A borrowed iterator over chunks in a [`BufList`]. |
| 331 | /// |
| 332 | /// Returned by [`BufList::iter`], and by the [`IntoIterator`] implementation for `&'a BufList`. |
| 333 | #[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:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 334 | pub struct Iterrust-analyzer cargo buf-list 1.1.2 imp/Iter#<'a> { |
| 335 | iterrust-analyzer cargo buf-list 1.1.2 imp/Iter#iter.: 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/::vec_dequerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/::Iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/iter/Iter#<'a, Bytesrust-analyzer cargo bytes 1.3.0 bytes/Bytes#>, |
| 336 | } |
| 337 | |
| 338 | impl<'a> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for Iterrust-analyzer cargo buf-list 1.1.2 imp/Iter#<'a> { |
| 339 | type Itemrust-analyzer cargo buf-list 1.1.2 imp/impl#[`Iter<'a>`][Iterator]Item# = &'a Bytesrust-analyzer cargo bytes 1.3.0 bytes/Bytes#; |
| 340 | |
| 341 | #[inline] |
| 342 | fn nextrust-analyzer cargo buf-list 1.1.2 imp/impl#[`Iter<'a>`][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo buf-list 1.1.2 imp/impl#[`Iter<'a>`][Iterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> { |
| 343 | self.iterrust-analyzer cargo buf-list 1.1.2 imp/Iter#iter..nextrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/iter/impl#[`Iter<'a, T>`][Iterator]next().() |
| 344 | } |
| 345 | |
| 346 | // These methods are implemented manually to forward to the underlying |
| 347 | // iterator. |
| 348 | |
| 349 | #[inline] |
| 350 | fn size_hintrust-analyzer cargo buf-list 1.1.2 imp/impl#[`Iter<'a>`][Iterator]size_hint().(&self) -> (usize, Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>) { |
| 351 | self.iterrust-analyzer cargo buf-list 1.1.2 imp/Iter#iter..size_hintrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/iter/impl#[`Iter<'a, T>`][Iterator]size_hint().() |
| 352 | } |
| 353 | |
| 354 | // fold has a special implementation, so forward it. |
| 355 | #[inline] |
| 356 | fn foldrust-analyzer cargo buf-list 1.1.2 imp/impl#[`Iter<'a>`][Iterator]fold().<B, F>(self, init: B, f: F) -> B |
| 357 | where |
| 358 | Selfrust-analyzer cargo buf-list 1.1.2 imp/impl#[`Iter<'a>`][Iterator]: Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#, |
| 359 | F: FnMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnMut#(B, Selfrust-analyzer cargo buf-list 1.1.2 imp/impl#[`Iter<'a>`][Iterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#) -> B, |
| 360 | { |
| 361 | self.iterrust-analyzer cargo buf-list 1.1.2 imp/Iter#iter..foldrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/iter/impl#[`Iter<'a, T>`][Iterator]fold().(init, f) |
| 362 | } |
| 363 | |
| 364 | // Can't implement try_fold as it uses `std::ops::Try` which isn't stable yet, as of Rust 1.67 |
| 365 | |
| 366 | #[inline] |
| 367 | fn nthrust-analyzer cargo buf-list 1.1.2 imp/impl#[`Iter<'a>`][Iterator]nth().(&mut self, n: usize) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo buf-list 1.1.2 imp/impl#[`Iter<'a>`][Iterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> { |
| 368 | self.iterrust-analyzer cargo buf-list 1.1.2 imp/Iter#iter..nthrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#nth().(n) |
| 369 | } |
| 370 | |
| 371 | #[inline] |
| 372 | fn lastrust-analyzer cargo buf-list 1.1.2 imp/impl#[`Iter<'a>`][Iterator]last().(self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo buf-list 1.1.2 imp/impl#[`Iter<'a>`][Iterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> |
| 373 | where |
| 374 | Selfrust-analyzer cargo buf-list 1.1.2 imp/impl#[`Iter<'a>`][Iterator]: Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#, |
| 375 | { |
| 376 | self.iterrust-analyzer cargo buf-list 1.1.2 imp/Iter#iter..lastrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/iter/impl#[`Iter<'a, T>`][Iterator]last().() |
| 377 | } |
| 378 | } |
| 379 | |
| 380 | impl<'a> DoubleEndedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/double_ended/DoubleEndedIterator# for Iterrust-analyzer cargo buf-list 1.1.2 imp/Iter#<'a> { |
| 381 | #[inline] |
| 382 | fn next_backrust-analyzer cargo buf-list 1.1.2 imp/impl#[`Iter<'a>`][DoubleEndedIterator]next_back().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo buf-list 1.1.2 imp/impl#[`Iter<'a>`][DoubleEndedIterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> { |
| 383 | self.iterrust-analyzer cargo buf-list 1.1.2 imp/Iter#iter..next_backrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/iter/impl#[`Iter<'a, T>`][DoubleEndedIterator]next_back().() |
| 384 | } |
| 385 | |
| 386 | #[inline] |
| 387 | fn rfoldrust-analyzer cargo buf-list 1.1.2 imp/impl#[`Iter<'a>`][DoubleEndedIterator]rfold().<B, F>(self, init: B, f: F) -> B |
| 388 | where |
| 389 | Selfrust-analyzer cargo buf-list 1.1.2 imp/impl#[`Iter<'a>`][DoubleEndedIterator]: Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#, |
| 390 | F: FnMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnMut#(B, Selfrust-analyzer cargo buf-list 1.1.2 imp/impl#[`Iter<'a>`][DoubleEndedIterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#) -> B, |
| 391 | { |
| 392 | self.iterrust-analyzer cargo buf-list 1.1.2 imp/Iter#iter..rfoldrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/iter/impl#[`Iter<'a, T>`][DoubleEndedIterator]rfold().(init, f) |
| 393 | } |
| 394 | |
| 395 | // Can't implement try_rfold as it uses `std::ops::Try` which isn't stable yet, as of Rust 1.67. |
| 396 | } |
| 397 | |
| 398 | impl<'a> ExactSizeIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/exact_size/ExactSizeIterator# for Iterrust-analyzer cargo buf-list 1.1.2 imp/Iter#<'a> { |
| 399 | #[inline] |
| 400 | fn lenrust-analyzer cargo buf-list 1.1.2 imp/impl#[`Iter<'a>`][ExactSizeIterator]len().(&self) -> usize { |
| 401 | self.iterrust-analyzer cargo buf-list 1.1.2 imp/Iter#iter..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/iter/impl#[`Iter<'_, T>`][ExactSizeIterator]len().() |
| 402 | } |
| 403 | } |
| 404 | |
| 405 | impl<'a> FusedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/marker/FusedIterator# for Iterrust-analyzer cargo buf-list 1.1.2 imp/Iter#<'a> {} |