pub fn consume(&mut self, mut size: usize) -> Vec<IoVec<&mut [u8]>> {
        let mut vectors: Vec<IoVec<&mut [u8]>> = Vec::with_capacity(8);

        while size > 0 && self.index < self.mem_slice.len() {
            let slice = self.mem_slice[self.index];
            let this_left = slice.len() - self.offset;

            match this_left.cmp(&size) {
                cmp::Ordering::Greater => {
                    // Safe because self.offset is valid and we have checked `size`.
                    let p = unsafe { slice.as_ptr().add(self.offset) };
                    let s = unsafe { from_raw_parts_mut(p, size) };
                    vectors.push(IoVec::from_mut_slice(s));
                    self.offset += size;
                    break;
                }
                cmp::Ordering::Equal => {
                    // Safe because self.offset is valid and we have checked `size`.
                    let p = unsafe { slice.as_ptr().add(self.offset) };
                    let s = unsafe { from_raw_parts_mut(p, size) };
                    vectors.push(IoVec::from_mut_slice(s));
                    self.index += 1;
                    self.offset = 0;
                    break;
                }
                cmp::Ordering::Less => {
                    let p = unsafe { slice.as_ptr().add(self.offset) };
                    let s = unsafe { from_raw_parts_mut(p, this_left) };
                    vectors.push(IoVec::from_mut_slice(s));
                    self.index += 1;
                    self.offset = 0;
                    size -= this_left;
                }
            }
        }

        vectors
    }
/// Consume `size` bytes of memory content from the cursor.
Consume `size` bytes of memory content from the cursor.
Consume ` size ` bytes of memory content from the cursor .
pub fn consume(&mut self, mut size: usize) -> Vec<IoVec<&mut [u8]>> {
        let mut vectors: Vec<IoVec<&mut [u8]>> = Vec::with_capacity(8);
        while size > 0 && self.index < self.mem_slice.len() {
            let slice = self.mem_slice[self.index];
            let this_left = slice.len() - self.offset;
            match this_left.cmp(&size) {
                cmp::Ordering::Greater => {
                    // Safe because self.offset is valid and we have checked `size`.
                    let p = unsafe { slice.as_ptr().add(self.offset) };
                    let s = unsafe { from_raw_parts_mut(p, size) };
                    vectors.push(IoVec::from_mut_slice(s));
                    self.offset += size;
                    break;
                }
                cmp::Ordering::Equal => {
                    // Safe because self.offset is valid and we have checked `size`.
                    let p = unsafe { slice.as_ptr().add(self.offset) };
                    let s = unsafe { from_raw_parts_mut(p, size) };
                    vectors.push(IoVec::from_mut_slice(s));
                    self.index += 1;
                    self.offset = 0;
                    break;
                }
                cmp::Ordering::Less => {
                    let p = unsafe { slice.as_ptr().add(self.offset) };
                    let s = unsafe { from_raw_parts_mut(p, this_left) };
                    vectors.push(IoVec::from_mut_slice(s));
                    self.index += 1;
                    self.offset = 0;
                    size -= this_left;
                }
            }
        }
        vectors
    }
pub fn consume ( & mut self , mut size : usize ) -> Vec < IoVec < & mut [ u8 ] > > { let mut vectors : Vec < IoVec < & mut [ u8 ] > > = Vec :: with_capacity ( 8 ) ; while size > 0 && self . index < self . mem_slice . len ( ) { let slice = self . mem_slice [ self . index ] ; let this_left = slice . len ( ) - self . offset ; match this_left . cmp ( & size ) { cmp :: Ordering :: Greater => { // Safe because self.offset is valid and we have checked `size`. let p = unsafe { slice . as_ptr ( ) . add ( self . offset ) } ; let s = unsafe { from_raw_parts_mut ( p , size ) } ; vectors . push ( IoVec :: from_mut_slice ( s ) ) ; self . offset += size ; break ; } cmp :: Ordering :: Equal => { // Safe because self.offset is valid and we have checked `size`. let p = unsafe { slice . as_ptr ( ) . add ( self . offset ) } ; let s = unsafe { from_raw_parts_mut ( p , size ) } ; vectors . push ( IoVec :: from_mut_slice ( s ) ) ; self . index += 1 ; self . offset = 0 ; break ; } cmp :: Ordering :: Less => { let p = unsafe { slice . as_ptr ( ) . add ( self . offset ) } ; let s = unsafe { from_raw_parts_mut ( p , this_left ) } ; vectors . push ( IoVec :: from_mut_slice ( s ) ) ; self . index += 1 ; self . offset = 0 ; size -= this_left ; } } } vectors }
Consume `size` bytes of memory content from the cursor.
Consume ` size ` bytes of memory content from the cursor .
&mut self
size
usize
&mut self
size
usize