fn seek(&mut self, pos: SeekFrom) -> io::Result<u64> {
        let result: u64;
        if let SeekFrom::Current(n) = pos {
            let remainder = (self.cap - self.pos) as i64;
            // it should be safe to assume that remainder fits within an i64 as the alternative
            // means we managed to allocate 8 ebibytes and that's absurd.
            // But it's not out of the realm of possibility for some weird underlying reader to
            // support seeking by i64::min_value() so we need to handle underflow when subtracting
            // remainder.
            if let Some(offset) = n.checked_sub(remainder) {
                result = try!(self.inner.seek(SeekFrom::Current(offset)));
            } else {
                // seek backwards by our remainder, and then by the offset
                try!(self.inner.seek(SeekFrom::Current(-remainder)));
                self.pos = self.cap; // empty the buffer
                result = try!(self.inner.seek(SeekFrom::Current(n)));
            }
        } else {
            // Seeking with Start/End doesn't care about our buffer length.
            result = try!(self.inner.seek(pos));
        }
        self.pos = self.cap; // empty the buffer
        Ok(result)
    }
/// Seek to an offset, in bytes, in the underlying reader.
///
/// The position used for seeking with `SeekFrom::Current(_)` is the
/// position the underlying reader would be at if the `BufReader` had no
/// internal buffer.
///
/// Seeking always discards the internal buffer, even if the seek position
/// would otherwise fall within it. This guarantees that calling
/// `.unwrap()` immediately after a seek yields the underlying reader at
/// the same position.
///
/// See `std::io::Seek` for more details.
///
/// Note: In the edge case where you're seeking with `SeekFrom::Current(n)`
/// where `n` minus the internal buffer length underflows an `i64`, two
/// seeks will be performed instead of one. If the second seek returns
/// `Err`, the underlying reader will be left at the same position it would
/// have if you seeked to `SeekFrom::Current(0)`.
Seek to an offset, in bytes, in the underlying reader.
The position used for seeking with `SeekFrom::Current(_)` is the
position the underlying reader would be at if the `BufReader` had no
internal buffer.

Seeking always discards the internal buffer, even if the seek position
would otherwise fall within it. This guarantees that calling
`.unwrap()` immediately after a seek yields the underlying reader at
the same position.

See `std::io::Seek` for more details.


Seek to an offset in bytes in the underlying reader . The position used for seeking with ` SeekFrom :: Current ( _ ) ` is the position the underlying reader would be at if the ` BufReader ` had no internal buffer . Seeking always discards the internal buffer even if the seek position would otherwise fall within it . This guarantees that calling ` . unwrap () ` immediately after a seek yields the underlying reader at the same position . See ` std :: io :: Seek ` for more details .
fn seek(&mut self, pos: SeekFrom) -> io::Result<u64> {
        let result: u64;
        if let SeekFrom::Current(n) = pos {
            let remainder = (self.cap - self.pos) as i64;
            // it should be safe to assume that remainder fits within an i64 as the alternative
            // means we managed to allocate 8 ebibytes and that's absurd.
            // But it's not out of the realm of possibility for some weird underlying reader to
            // support seeking by i64::min_value() so we need to handle underflow when subtracting
            // remainder.
            if let Some(offset) = n.checked_sub(remainder) {
                result = try!(self.inner.seek(SeekFrom::Current(offset)));
            } else {
                // seek backwards by our remainder, and then by the offset
                try!(self.inner.seek(SeekFrom::Current(-remainder)));
                self.pos = self.cap; // empty the buffer
                result = try!(self.inner.seek(SeekFrom::Current(n)));
            }
        } else {
            // Seeking with Start/End doesn't care about our buffer length.
            result = try!(self.inner.seek(pos));
        }
        self.pos = self.cap; // empty the buffer
        Ok(result)
    }
fn seek ( & mut self , pos : SeekFrom ) -> io :: Result < u64 > { let result : u64 ; if let SeekFrom :: Current ( n ) = pos { let remainder = ( self . cap - self . pos ) as i64 ; // it should be safe to assume that remainder fits within an i64 as the alternative // means we managed to allocate 8 ebibytes and that's absurd. // But it's not out of the realm of possibility for some weird underlying reader to // support seeking by i64::min_value() so we need to handle underflow when subtracting // remainder. if let Some ( offset ) = n . checked_sub ( remainder ) { result = try ! ( self inner seek ( SeekFrom Current ( offset ) ) ) ; } else { // seek backwards by our remainder, and then by the offset try ! ( self inner seek ( SeekFrom Current ( remainder ) ) ) ; self . pos = self . cap ; // empty the buffer result = try ! ( self inner seek ( SeekFrom Current ( n ) ) ) ; } } else { // Seeking with Start/End doesn't care about our buffer length. result = try ! ( self inner seek ( pos ) ) ; } self . pos = self . cap ; // empty the buffer Ok ( result ) }
Seek to an offset, in bytes, in the underlying reader.
Seek to an offset in bytes in the underlying reader .
&mut self
pos
SeekFrom