Skip to content

Commit

Permalink
Rollup merge of rust-lang#59906 - czipperz:bufwriter-use-getmut, r=ke…
Browse files Browse the repository at this point in the history
…nnytm

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.
  • Loading branch information
Centril authored Apr 14, 2019
2 parents fd4a336 + ac5e755 commit 271eb8f
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 271eb8f

Please sign in to comment.