Browse Source

add purge()

this is necessary for __fpurge
Matija Skala 5 years ago
parent
commit
cb21c01918
1 changed files with 9 additions and 0 deletions
  1. 9 0
      src/b9adc3327ec7d2820ab2db8bb3cc2a0196a8375d/buffered.rs

+ 9 - 0
src/b9adc3327ec7d2820ab2db8bb3cc2a0196a8375d/buffered.rs

@@ -475,6 +475,10 @@ impl<W: Write> BufWriter<W> {
         ret
     }
 
+    pub fn purge_buf(&mut self) {
+        self.buf = vec![];
+    }
+
     /// Gets a reference to the underlying writer.
     ///
     /// # Examples
@@ -836,6 +840,11 @@ impl<W: Write> LineWriter<W> {
             }, e)
         })
     }
+
+    pub fn purge(&mut self) {
+        self.inner.purge_buf();
+        self.need_flush = false;
+    }
 }
 
 impl<W: Write> Write for LineWriter<W> {