mirror of
https://github.com/tokio-rs/bytes.git
synced 2026-08-10 00:00:09 +02:00
The Reader can implement BufReader naturally (#232)
There's no reason the user should be forced to wrap it in BufReader in case the trait is needed, because the Reader has all the bits for supporting it naturally.
This commit is contained in:
committed by
Carl Lerche
parent
e64a123d00
commit
7c3085aaec
@@ -86,3 +86,12 @@ impl<B: Buf + Sized> io::Read for Reader<B> {
|
||||
Ok(len)
|
||||
}
|
||||
}
|
||||
|
||||
impl<B: Buf + Sized> io::BufRead for Reader<B> {
|
||||
fn fill_buf(&mut self) -> io::Result<&[u8]> {
|
||||
Ok(self.buf.bytes())
|
||||
}
|
||||
fn consume(&mut self, amt: usize) {
|
||||
self.buf.advance(amt)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user