Rollup merge of #59906 - czipperz:bufwriter-use-getmut, r=kennytm

Make BufWriter use get_mut instead of manipulating inner in Write implementation

`get_mut` allows us to abstract over the implementation detail of inner being optional.
This commit is contained in:
Mazdak Farrokhzad 2019-04-14 17:49:24 +02:00 committed by GitHub
commit 271eb8fc5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -601,7 +601,7 @@ impl<W: Write> Write for BufWriter<W> {
}
if buf.len() >= self.buf.capacity() {
self.panicked = true;
let r = self.inner.as_mut().unwrap().write(buf);
let r = self.get_mut().write(buf);
self.panicked = false;
r
} else {
@ -616,7 +616,7 @@ impl<W: Write> Write for BufWriter<W> {
}
if total_len >= self.buf.capacity() {
self.panicked = true;
let r = self.inner.as_mut().unwrap().write_vectored(bufs);
let r = self.get_mut().write_vectored(bufs);
self.panicked = false;
r
} else {