BufWriter: simplify buffer draining

This commit is contained in:
Tyson Nottingham 2021-04-13 10:09:37 -07:00
parent 85bc88df5f
commit 0f29dc40f8

View File

@ -155,11 +155,7 @@ impl<W: Write> BufWriter<W> {
impl Drop for BufGuard<'_> { impl Drop for BufGuard<'_> {
fn drop(&mut self) { fn drop(&mut self) {
if self.written > 0 { if self.written > 0 {
if self.done() { self.buffer.drain(..self.written);
self.buffer.clear();
} else {
self.buffer.drain(..self.written);
}
} }
} }
} }