diff options
| author | bors <bors@rust-lang.org> | 2014-11-25 09:21:45 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-11-25 09:21:45 +0000 |
| commit | f6cb58caeedf509cc80dd376bbb2541a0446046b (patch) | |
| tree | 342842df92d03e14065608b8bef510e7b4980b05 /src/libstd/io | |
| parent | 0c1d853fba0068f9fd34b43a565ded01b199506c (diff) | |
| parent | f1f6c1286f24f6f762a9b195ac678b55d20c9a9b (diff) | |
| download | rust-f6cb58caeedf509cc80dd376bbb2541a0446046b.tar.gz rust-f6cb58caeedf509cc80dd376bbb2541a0446046b.zip | |
auto merge of #19149 : alexcrichton/rust/issue-19091, r=aturon
This change applies the conventions to unwrap listed in [RFC 430][rfc] to rename non-failing `unwrap` methods to `into_inner`. This is a breaking change, but all `unwrap` methods are retained as `#[deprecated]` for the near future. To update code rename `unwrap` method calls to `into_inner`. [rfc]: https://github.com/rust-lang/rfcs/pull/430 [breaking-change] cc #19091
Diffstat (limited to 'src/libstd/io')
| -rw-r--r-- | src/libstd/io/buffered.rs | 26 | ||||
| -rw-r--r-- | src/libstd/io/mem.rs | 14 | ||||
| -rw-r--r-- | src/libstd/io/tempfile.rs | 6 | ||||
| -rw-r--r-- | src/libstd/io/util.rs | 12 |
4 files changed, 47 insertions, 11 deletions
diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs index 25e85f33aa5..148323762c8 100644 --- a/src/libstd/io/buffered.rs +++ b/src/libstd/io/buffered.rs @@ -83,7 +83,11 @@ impl<R: Reader> BufferedReader<R> { /// Unwraps this `BufferedReader`, returning the underlying reader. /// /// Note that any leftover data in the internal buffer is lost. - pub fn unwrap(self) -> R { self.inner } + pub fn into_inner(self) -> R { self.inner } + + /// Deprecated, use into_inner() instead + #[deprecated = "renamed to into_inner()"] + pub fn unwrap(self) -> R { self.into_inner() } } impl<R: Reader> Buffer for BufferedReader<R> { @@ -180,11 +184,15 @@ impl<W: Writer> BufferedWriter<W> { /// Unwraps this `BufferedWriter`, returning the underlying writer. /// /// The buffer is flushed before returning the writer. - pub fn unwrap(mut self) -> W { + pub fn into_inner(mut self) -> W { // FIXME(#12628): is panicking the right thing to do if flushing panicks? self.flush_buf().unwrap(); self.inner.take().unwrap() } + + /// Deprecated, use into_inner() instead + #[deprecated = "renamed to into_inner()"] + pub fn unwrap(self) -> W { self.into_inner() } } impl<W: Writer> Writer for BufferedWriter<W> { @@ -244,7 +252,11 @@ impl<W: Writer> LineBufferedWriter<W> { /// Unwraps this `LineBufferedWriter`, returning the underlying writer. /// /// The internal buffer is flushed before returning the writer. - pub fn unwrap(self) -> W { self.inner.unwrap() } + pub fn into_inner(self) -> W { self.inner.into_inner() } + + /// Deprecated, use into_inner() instead + #[deprecated = "renamed to into_inner()"] + pub fn unwrap(self) -> W { self.into_inner() } } impl<W: Writer> Writer for LineBufferedWriter<W> { @@ -341,10 +353,14 @@ impl<S: Stream> BufferedStream<S> { /// /// The internal buffer is flushed before returning the stream. Any leftover /// data in the read buffer is lost. - pub fn unwrap(self) -> S { + pub fn into_inner(self) -> S { let InternalBufferedWriter(w) = self.inner.inner; - w.unwrap() + w.into_inner() } + + /// Deprecated, use into_inner() instead + #[deprecated = "renamed to into_inner()"] + pub fn unwrap(self) -> S { self.into_inner() } } impl<S: Stream> Buffer for BufferedStream<S> { diff --git a/src/libstd/io/mem.rs b/src/libstd/io/mem.rs index 21de6c2013d..f27951f263d 100644 --- a/src/libstd/io/mem.rs +++ b/src/libstd/io/mem.rs @@ -62,7 +62,7 @@ impl Writer for Vec<u8> { /// let mut w = MemWriter::new(); /// w.write(&[0, 1, 2]); /// -/// assert_eq!(w.unwrap(), vec!(0, 1, 2)); +/// assert_eq!(w.into_inner(), vec!(0, 1, 2)); /// ``` #[deprecated = "use the Vec<u8> Writer implementation directly"] #[deriving(Clone)] @@ -95,7 +95,11 @@ impl MemWriter { /// Unwraps this `MemWriter`, returning the underlying buffer #[inline] - pub fn unwrap(self) -> Vec<u8> { self.buf } + pub fn into_inner(self) -> Vec<u8> { self.buf } + + /// Deprecated, use into_inner() instead + #[deprecated = "renamed to into_inner()"] + pub fn unwrap(self) -> Vec<u8> { self.into_inner() } } impl Writer for MemWriter { @@ -150,7 +154,11 @@ impl MemReader { /// Unwraps this `MemReader`, returning the underlying buffer #[inline] - pub fn unwrap(self) -> Vec<u8> { self.buf } + pub fn into_inner(self) -> Vec<u8> { self.buf } + + /// Deprecated, use into_inner() instead + #[deprecated = "renamed to into_inner()"] + pub fn unwrap(self) -> Vec<u8> { self.into_inner() } } impl Reader for MemReader { diff --git a/src/libstd/io/tempfile.rs b/src/libstd/io/tempfile.rs index a232231733d..4788ba79b7f 100644 --- a/src/libstd/io/tempfile.rs +++ b/src/libstd/io/tempfile.rs @@ -73,11 +73,15 @@ impl TempDir { /// Unwrap the wrapped `std::path::Path` from the `TempDir` wrapper. /// This discards the wrapper so that the automatic deletion of the /// temporary directory is prevented. - pub fn unwrap(self) -> Path { + pub fn into_inner(self) -> Path { let mut tmpdir = self; tmpdir.path.take().unwrap() } + /// Deprecated, use into_inner() instead + #[deprecated = "renamed to into_inner()"] + pub fn unwrap(self) -> Path { self.into_inner() } + /// Access the wrapped `std::path::Path` to the temporary directory. pub fn path<'a>(&'a self) -> &'a Path { self.path.as_ref().unwrap() diff --git a/src/libstd/io/util.rs b/src/libstd/io/util.rs index 4d491beb87b..8e0cd660816 100644 --- a/src/libstd/io/util.rs +++ b/src/libstd/io/util.rs @@ -28,7 +28,11 @@ impl<R: Reader> LimitReader<R> { } /// Consumes the `LimitReader`, returning the underlying `Reader`. - pub fn unwrap(self) -> R { self.inner } + pub fn into_inner(self) -> R { self.inner } + + /// Deprecated, use into_inner() instead + #[deprecated = "renamed to into_inner"] + pub fn unwrap(self) -> R { self.into_inner() } /// Returns the number of bytes that can be read before the `LimitReader` /// will return EOF. @@ -207,10 +211,14 @@ impl<R: Reader, W: Writer> TeeReader<R, W> { /// Consumes the `TeeReader`, returning the underlying `Reader` and /// `Writer`. - pub fn unwrap(self) -> (R, W) { + pub fn into_inner(self) -> (R, W) { let TeeReader { reader, writer } = self; (reader, writer) } + + /// Deprecated, use into_inner() instead + #[deprecated = "renamed to into_inner"] + pub fn unwrap(self) -> (R, W) { self.into_inner() } } impl<R: Reader, W: Writer> Reader for TeeReader<R, W> { |
