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 94e5843
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions src/buf/take.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,29 @@ 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)]);
const LEN: usize = 16;
let mut slices: [IoSlice<'a>; LEN] = [
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(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 94e5843

Please sign in to comment.