File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -75,6 +75,26 @@ impl<B: Buf + Sized> io::BufRead for Reader<B> {
7575 fn fill_buf ( & mut self ) -> io:: Result < & [ u8 ] > {
7676 Ok ( self . buf . chunk ( ) )
7777 }
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+ ///
7898 fn consume ( & mut self , amt : usize ) {
7999 self . buf . advance ( amt)
80100 }
You can’t perform that action at this time.
0 commit comments