pub fn refill(&mut self, mut min_len: usize) {
        // Move the buffer contents to the beginning to make more space at the
        // end.
        if self.base > 0 {
            for i in 0..(self.tail - self.base) {
                self.buf[i] = self.buf[self.base + i]
            }
            self.pos -= self.base;
            self.tail -= self.base;
            min_len -= self.base;
            self.base = 0;
        }
        assert!(self.base == 0);

        // Increase the buffer size to make sure the requested min_len can be
        // accomodated.
        let cur_len = self.buf.len();
        if min_len > cur_len {
            let new_len = max(cur_len * 2, 32);
            self.buf.resize(new_len, 0);
        }
        assert!(self.buf.len() >= min_len);

        // Keep reading data until at least min_len bytes are in the buffer.
        // Note that this will usually fill in the entire buffer.
        while min_len > self.tail {
            let nread = {
                let dst = &mut self.buf[self.tail..];
                let nread = self.rd.read(dst).unwrap();
                nread
            };
            if nread == 0 {
                break;
            }
            self.tail += nread;
        }
    }
/// Grow and fill the internal buffer such that at least min_len characters
/// are present, or the end of the file has been reached. This function may
/// shift the buffer contents around, in which case previous buffer indices
/// become invalid. Recalculate all indices derived from `base`, `pos`, or
/// `tail` after a call to this function.
Grow and fill the internal buffer such that at least min_len characters
are present, or the end of the file has been reached. This function may
shift the buffer contents around, in which case previous buffer indices
become invalid.
Grow and fill the internal buffer such that at least min_len characters are present or the end of the file has been reached . This function may shift the buffer contents around in which case previous buffer indices become invalid .
pub fn refill(&mut self, mut min_len: usize) {
        // Move the buffer contents to the beginning to make more space at the
        // end.
        if self.base > 0 {
            for i in 0..(self.tail - self.base) {
                self.buf[i] = self.buf[self.base + i]
            }
            self.pos -= self.base;
            self.tail -= self.base;
            min_len -= self.base;
            self.base = 0;
        }
        assert!(self.base == 0);
        // Increase the buffer size to make sure the requested min_len can be
        // accomodated.
        let cur_len = self.buf.len();
        if min_len > cur_len {
            let new_len = max(cur_len * 2, 32);
            self.buf.resize(new_len, 0);
        }
        assert!(self.buf.len() >= min_len);
        // Keep reading data until at least min_len bytes are in the buffer.
        // Note that this will usually fill in the entire buffer.
        while min_len > self.tail {
            let nread = {
                let dst = &mut self.buf[self.tail..];
                let nread = self.rd.read(dst).unwrap();
                nread
            };
            if nread == 0 {
                break;
            }
            self.tail += nread;
        }
    }
pub fn refill ( & mut self , mut min_len : usize ) { // Move the buffer contents to the beginning to make more space at the // end. if self . base > 0 { for i in 0 .. ( self . tail - self . base ) { self . buf [ i ] = self . buf [ self . base + i ] } self . pos -= self . base ; self . tail -= self . base ; min_len -= self . base ; self . base = 0 ; } assert ! ( self base 0 ) ; // Increase the buffer size to make sure the requested min_len can be // accomodated. let cur_len = self . buf . len ( ) ; if min_len > cur_len { let new_len = max ( cur_len * 2 , 32 ) ; self . buf . resize ( new_len , 0 ) ; } assert ! ( self buf len ( ) min_len ) ; // Keep reading data until at least min_len bytes are in the buffer. // Note that this will usually fill in the entire buffer. while min_len > self . tail { let nread = { let dst = & mut self . buf [ self . tail .. ] ; let nread = self . rd . read ( dst ) . unwrap ( ) ; nread } ; if nread == 0 { break ; } self . tail += nread ; } }
Grow and fill the internal buffer such that at least min_len characters
are present, or the end of the file has been reached.
Grow and fill the internal buffer such that at least min_len characters are present or the end of the file has been reached .
&mut self
min_len
usize
&mut self
min_len
usize