Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/buf/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,27 @@ impl<B: Buf + Sized> io::BufRead for Reader<B> {
fn fill_buf(&mut self) -> io::Result<&[u8]> {
Ok(self.buf.chunk())
}
/// consume `amt` bytes from the buffer.
///
/// Calls [`Buf::advance`] internally: If `amt` > `get_ref().remaining()` it
/// may **Panic** or advance to the end of the buf.
///
/// # Examples
/// ```rust
/// use bytes::Buf;
/// use std::io::{Read, BufRead};
///
/// let mut buf = b"hello world".reader();
/// let mut dst = vec![];
///
/// // skip b"hello "
/// buf.consume(6);
/// // read b"world"
/// buf.read_to_end(&mut dst).unwrap();
///
/// assert_eq!(dst, b"world");
/// ```
///
fn consume(&mut self, amt: usize) {
self.buf.advance(amt)
}
Expand Down