fix stream position and term comparison bugs (#1472)

This commit is contained in:
Mark Thom
2022-05-22 14:15:56 -06:00
parent e486862db8
commit 10a11c293e
3 changed files with 35 additions and 8 deletions

View File

@@ -61,6 +61,14 @@ impl<R> CharReader<R> {
pub fn inner_mut(&mut self) -> &mut R {
&mut self.inner
}
// Return the number of bytes remaining to be read. Useful for,
// e.g., determining the position relative to the end of the
// owning stream.
#[inline]
pub fn rem_buf_len(&self) -> usize {
self.buf.len() - self.pos
}
}
pub trait CharRead {
@@ -96,7 +104,7 @@ impl<R> CharReader<R> {
self.inner
}
fn reset_buffer(&mut self) {
pub fn reset_buffer(&mut self) {
self.buf.clear();
self.pos = 0;
}