mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-08 01:28:18 +03:00
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:
@@ -601,7 +601,7 @@ fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
|
||||
}
|
||||
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 @@ fn write_vectored(&mut self, bufs: &[IoVec<'_>]) -> io::Result<usize> {
|
||||
}
|
||||
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 {
|
||||
|
||||
Reference in New Issue
Block a user