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,14 +155,10 @@ impl<W: Write> BufWriter<W> {
impl Drop for BufGuard<'_> {
fn drop(&mut self) {
if self.written > 0 {
if self.done() {
self.buffer.clear();
} else {
self.buffer.drain(..self.written);
}
}
}
}
let mut guard = BufGuard::new(&mut self.buf);
let inner = self.inner.as_mut().unwrap();