This will be obviated by [rust-lang/rust#62726]. [rust-lang/rust#62726]: https://github.com/rust-lang/rust/issues/62726.
(bufs: &'b mut [IoSlice<'a>], n: usize)
| 146 | /// |
| 147 | /// [rust-lang/rust#62726]: https://github.com/rust-lang/rust/issues/62726. |
| 148 | fn advance<'a, 'b>(bufs: &'b mut [IoSlice<'a>], n: usize) -> &'b mut [IoSlice<'a>] { |
| 149 | // Number of buffers to remove. |
| 150 | let mut remove = 0; |
| 151 | // Total length of all the to be removed buffers. |
| 152 | let mut accumulated_len = 0; |
| 153 | for buf in bufs.iter() { |
| 154 | if accumulated_len + buf.len() > n { |
| 155 | break; |
| 156 | } else { |
| 157 | accumulated_len += buf.len(); |
| 158 | remove += 1; |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | #[allow(clippy::indexing_slicing)] |
| 163 | let bufs = &mut bufs[remove..]; |
| 164 | if let Some(first) = bufs.first_mut() { |
| 165 | let advance_by = n - accumulated_len; |
| 166 | let mut ptr = first.as_ptr(); |
| 167 | let mut len = first.len(); |
| 168 | unsafe { |
| 169 | ptr = ptr.add(advance_by); |
| 170 | len -= advance_by; |
| 171 | *first = IoSlice::<'a>::new(slice::from_raw_parts::<'a>(ptr, len)); |
| 172 | } |
| 173 | } |
| 174 | bufs |
| 175 | } |
| 176 | |
| 177 | /// This will be obviated by [rust-lang/rust#62726]. |
| 178 | /// |