From ac5e755164be38d6485e3ceb80d472147a0d9552 Mon Sep 17 00:00:00 2001 From: Chris Gregory Date: Thu, 11 Apr 2019 23:57:29 -0500 Subject: [PATCH] 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. --- src/libstd/io/buffered.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs index 3370a447fcc8e..bf406bb9b0ba7 100644 --- a/src/libstd/io/buffered.rs +++ b/src/libstd/io/buffered.rs @@ -601,7 +601,7 @@ impl Write for BufWriter { } 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 Write for BufWriter { } 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 {