Skip to content

Commit

Permalink
IoSlice is not Copy on MSRV 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Darksonn committed Jan 13, 2025
1 parent 2310cd3 commit 10b5341
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/buf/take.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,28 @@ impl<T: Buf> Buf for Take<T> {
return 0;
}

let mut slices = [IoSlice::new(&[]); 16];

let cnt = self.inner.chunks_vectored(&mut slices[..dst.len().min(16)]);
let mut slices = [
IoSlice::new(&[]),
IoSlice::new(&[]),
IoSlice::new(&[]),
IoSlice::new(&[]),
IoSlice::new(&[]),
IoSlice::new(&[]),
IoSlice::new(&[]),
IoSlice::new(&[]),
IoSlice::new(&[]),
IoSlice::new(&[]),
IoSlice::new(&[]),
IoSlice::new(&[]),
IoSlice::new(&[]),
IoSlice::new(&[]),
IoSlice::new(&[]),
IoSlice::new(&[]),
];

let cnt = self
.inner
.chunks_vectored(&mut slices[..dst.len().min(slices.len())]);
let mut limit = self.limit;
for (i, (dst, slice)) in dst[..cnt].iter_mut().zip(slices.iter()).enumerate() {
if let Some(buf) = slice.get(..limit) {
Expand Down

0 comments on commit 10b5341

Please sign in to comment.