correct peek_byte/2 bugs (#1882)

This commit is contained in:
Mark
2023-07-13 12:23:20 -06:00
parent cfc49243c8
commit b051f39145
3 changed files with 21 additions and 7 deletions

View File

@@ -128,6 +128,19 @@ impl<R: Read> CharReader<R> {
Ok(&self.buf[self.pos..])
}
pub fn peek_byte(&mut self) -> Option<io::Result<u8>> {
match self.refresh_buffer() {
Ok(_buf) => {}
Err(e) => return Some(Err(e)),
}
return if let Some(b) = self.buf.get(0).cloned() {
Some(Ok(b))
} else {
None
};
}
}
impl<R: Read> CharRead for CharReader<R> {