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)
| 340 | /// |
| 341 | /// [rust-lang/rust#62726]: https://github.com/rust-lang/rust/issues/62726. |
| 342 | fn advance<'a, 'b>(bufs: &'b mut [IoSlice<'a>], n: usize) -> &'b mut [IoSlice<'a>] { |
| 343 | // Number of buffers to remove. |
| 344 | let mut remove = 0; |
| 345 | // Total length of all the to be removed buffers. |
| 346 | let mut accumulated_len = 0; |
| 347 | for buf in bufs.iter() { |
| 348 | if accumulated_len + buf.len() > n { |
| 349 | break; |
| 350 | } else { |
| 351 | accumulated_len += buf.len(); |
| 352 | remove += 1; |
| 353 | } |
| 354 | } |
| 355 | |
| 356 | #[allow(clippy::indexing_slicing)] |
| 357 | let bufs = &mut bufs[remove..]; |
| 358 | if let Some(first) = bufs.first_mut() { |
| 359 | let advance_by = n - accumulated_len; |
| 360 | let mut ptr = first.as_ptr(); |
| 361 | let mut len = first.len(); |
| 362 | unsafe { |
| 363 | ptr = ptr.add(advance_by); |
| 364 | len -= advance_by; |
| 365 | *first = IoSlice::<'a>::new(slice::from_raw_parts::<'a>(ptr, len)); |
| 366 | } |
| 367 | } |
| 368 | bufs |
| 369 | } |
| 370 | |
| 371 | /// This will be obviated by [rust-lang/rust#62726]. |
| 372 | /// |
no outgoing calls
no test coverage detected