Skip to content

Commit

Permalink
Make BufWriter use get_mut instead of manipulating inner in Write imp…
Browse files Browse the repository at this point in the history
…lementation

get_mut allows us to abstract over the implementation detail of inner being
optional.
  • Loading branch information
czipperz committed Apr 12, 2019
1 parent 3de0106 commit ac5e755
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/libstd/io/buffered.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down

0 comments on commit ac5e755

Please sign in to comment.