We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 141cbc2 commit feefaddCopy full SHA for feefadd
src/buf/reader.rs
@@ -75,6 +75,26 @@ impl<B: Buf + Sized> io::BufRead for Reader<B> {
75
fn fill_buf(&mut self) -> io::Result<&[u8]> {
76
Ok(self.buf.chunk())
77
}
78
+ /// consume `amt` bytes from the buffer.
79
+ ///
80
+ /// Calls [`Buf::advance`] internally and will therefore not lead to a logic error.
81
82
+ /// # Examples
83
+ /// ```rust
84
+ /// use bytes::Buf;
85
+ /// use std::io::{Read, BufRead};
86
87
+ /// let mut buf = b"hello world".reader();
88
+ /// let mut dst = vec![];
89
90
+ /// // skip b"hello "
91
+ /// buf.consume(6);
92
+ /// // read b"world"
93
+ /// buf.read_to_end(&mut dst).unwrap();
94
95
+ /// assert_eq!(dst, b"world");
96
+ /// ```
97
98
fn consume(&mut self, amt: usize) {
99
self.buf.advance(amt)
100
0 commit comments