fn consume(&mut self, need: usize, src: &mut SourcePtr) -> bool {
        assert!(need >= self.cnt);
        assert!(need <= self.data.len());

        let cnt = cmp::min(need - self.cnt, src.available());
        if cnt > 0 {
            // make slices same size for copy_from_slice
            let d = &mut self.data[self.cnt..self.cnt + cnt];
            d.copy_from_slice(src.data(cnt));
            src.advance(cnt);
            self.cnt += cnt;
        }

        // do we have all data ?
        need == self.cnt
    }
// Try to read `need` bytes from `src` and update src
// return true when enough data was read, false otherwise
Try to read `need` bytes from `src` and update src
return true when enough data was read, false otherwise
Try to read ` need ` bytes from ` src ` and update src return true when enough data was read false otherwise
fn consume(&mut self, need: usize, src: &mut SourcePtr) -> bool {
        assert!(need >= self.cnt);
        assert!(need <= self.data.len());
        let cnt = cmp::min(need - self.cnt, src.available());
        if cnt > 0 {
            // make slices same size for copy_from_slice
            let d = &mut self.data[self.cnt..self.cnt + cnt];
            d.copy_from_slice(src.data(cnt));
            src.advance(cnt);
            self.cnt += cnt;
        }
        // do we have all data ?
        need == self.cnt
    }
fn consume ( & mut self , need : usize , src : & mut SourcePtr ) -> bool { assert ! ( need self cnt ) ; assert ! ( need self data len ( ) ) ; let cnt = cmp :: min ( need - self . cnt , src . available ( ) ) ; if cnt > 0 { // make slices same size for copy_from_slice let d = & mut self . data [ self . cnt .. self . cnt + cnt ] ; d . copy_from_slice ( src . data ( cnt ) ) ; src . advance ( cnt ) ; self . cnt += cnt ; } // do we have all data ? need == self . cnt }
Try to read `need` bytes from `src` and update src
return true when enough data was read, false otherwise
Try to read ` need ` bytes from ` src ` and update src return true when enough data was read false otherwise
&mut self
need
usize
src
&mut SourcePtr
&mut self
need
usize
src
&mut SourcePtr