Add clear method to RingBuf

This commit is contained in:
Nandor Kracser
2015-09-25 09:45:55 -07:00
committed by Carl Lerche
parent 4ce8b1c2c8
commit a76dd8ed0e
2 changed files with 23 additions and 0 deletions
+7
View File
@@ -91,6 +91,13 @@ impl RingBuf {
}
}
/// Resets all internal state to the initial state.
pub fn clear(&mut self) {
self.pos = 0;
self.len = 0;
self.mark = Mark::NoMark;
}
/// Returns the number of bytes remaining to read.
fn read_remaining(&self) -> usize {
self.len