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]
Closes #13159
cc #19091
14 files changed:
impl<T> MoveItems<T> {
#[inline]
/// Drops all items that have not yet been moved and returns the empty vector.
impl<T> MoveItems<T> {
#[inline]
/// Drops all items that have not yet been moved and returns the empty vector.
- pub fn unwrap(mut self) -> Vec<T> {
+ pub fn into_inner(mut self) -> Vec<T> {
unsafe {
for _x in self { }
let MoveItems { allocation, cap, ptr: _ptr, end: _end } = self;
unsafe {
for _x in self { }
let MoveItems { allocation, cap, ptr: _ptr, end: _end } = self;
Vec { ptr: allocation, cap: cap, len: 0 }
}
}
Vec { ptr: allocation, cap: cap, len: 0 }
}
}
+
+ /// Deprecated, use into_inner() instead
+ #[deprecated = "renamed to into_inner()"]
+ pub fn unwrap(self) -> Vec<T> { self.into_inner() }
}
impl<T> Iterator<T> for MoveItems<T> {
}
impl<T> Iterator<T> for MoveItems<T> {
}
/// Consumes the `RefCell`, returning the wrapped value.
}
/// Consumes the `RefCell`, returning the wrapped value.
- #[unstable = "may be renamed, depending on global conventions"]
- pub fn unwrap(self) -> T {
+ #[unstable = "recently renamed per RFC 430"]
+ pub fn into_inner(self) -> T {
// Since this function takes `self` (the `RefCell`) by value, the
// compiler statically verifies that it is not currently borrowed.
// Therefore the following assertion is just a `debug_assert!`.
debug_assert!(self.borrow.get() == UNUSED);
// Since this function takes `self` (the `RefCell`) by value, the
// compiler statically verifies that it is not currently borrowed.
// Therefore the following assertion is just a `debug_assert!`.
debug_assert!(self.borrow.get() == UNUSED);
- unsafe{self.value.unwrap()}
+ unsafe { self.value.into_inner() }
+ /// Deprecated, use into_inner() instead
+ #[deprecated = "renamed to into_inner()"]
+ pub fn unwrap(self) -> T { self.into_inner() }
+
/// Attempts to immutably borrow the wrapped value.
///
/// The borrow lasts until the returned `Ref` exits scope. Multiple
/// Attempts to immutably borrow the wrapped value.
///
/// The borrow lasts until the returned `Ref` exits scope. Multiple
#[inline]
#[unstable = "conventions around the name `unwrap` are still under \
development"]
#[inline]
#[unstable = "conventions around the name `unwrap` are still under \
development"]
- pub unsafe fn unwrap(self) -> T { self.value }
+ pub unsafe fn into_inner(self) -> T { self.value }
+
+ /// Deprecated, use into_inner() instead
+ #[deprecated = "renamed to into_inner()"]
+ pub unsafe fn unwrap(self) -> T { self.into_inner() }
}
tcx.sess.abort_if_errors();
}
tcx.sess.abort_if_errors();
- *tcx.node_lint_levels.borrow_mut() = cx.node_levels.unwrap();
+ *tcx.node_lint_levels.borrow_mut() = cx.node_levels.into_inner();
pub fn build_string(f: |RustStringRef|) -> Option<String> {
let mut buf = RefCell::new(Vec::new());
f(&mut buf as RustStringRepr as RustStringRef);
pub fn build_string(f: |RustStringRef|) -> Option<String> {
let mut buf = RefCell::new(Vec::new());
f(&mut buf as RustStringRepr as RustStringRef);
- String::from_utf8(buf.unwrap()).ok()
+ String::from_utf8(buf.into_inner()).ok()
}
pub unsafe fn twine_to_string(tr: TwineRef) -> String {
}
pub unsafe fn twine_to_string(tr: TwineRef) -> String {
let mut panicked = false;
for future in futures.into_iter() {
let mut panicked = false;
for future in futures.into_iter() {
- match future.unwrap() {
+ match future.into_inner() {
Ok(()) => {},
Err(_) => {
panicked = true;
Ok(()) => {},
Err(_) => {
panicked = true;
///
/// Prefer `.as_ptr()` when just retrieving a pointer to the
/// string data, as that does not relinquish ownership.
///
/// Prefer `.as_ptr()` when just retrieving a pointer to the
/// string data, as that does not relinquish ownership.
- pub unsafe fn unwrap(mut self) -> *const libc::c_char {
+ pub unsafe fn into_inner(mut self) -> *const libc::c_char {
self.owns_buffer_ = false;
self.buf
}
self.owns_buffer_ = false;
self.buf
}
+ /// Deprecated, use into_inner() instead
+ #[deprecated = "renamed to into_inner()"]
+ pub unsafe fn unwrap(self) -> *const libc::c_char { self.into_inner() }
+
/// Return the number of bytes in the CString (not including the NUL
/// terminator).
#[inline]
/// Return the number of bytes in the CString (not including the NUL
/// terminator).
#[inline]
/// Note that if you want to access the underlying pointer without
/// cancelling the destructor, you can simply call `transmute` on the return
/// value of `get(0)`.
/// Note that if you want to access the underlying pointer without
/// cancelling the destructor, you can simply call `transmute` on the return
/// value of `get(0)`.
- pub unsafe fn unwrap(mut self) -> *mut T {
+ pub unsafe fn into_inner(mut self) -> *mut T {
self.dtor = None;
self.base
}
self.dtor = None;
self.base
}
+ /// Deprecated, use into_inner() instead
+ #[deprecated = "renamed to into_inner()"]
+ pub unsafe fn unwrap(self) -> *mut T { self.into_inner() }
+
/// Returns the number of items in this vector.
pub fn len(&self) -> uint { self.len }
/// Returns the number of items in this vector.
pub fn len(&self) -> uint { self.len }
/// Unwraps this `BufferedReader`, returning the underlying reader.
///
/// Note that any leftover data in the internal buffer is lost.
/// 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> {
}
impl<R: Reader> Buffer for BufferedReader<R> {
/// Unwraps this `BufferedWriter`, returning the underlying writer.
///
/// The buffer is flushed before returning the writer.
/// 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()
}
// 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> {
}
impl<W: Writer> Writer for BufferedWriter<W> {
/// Unwraps this `LineBufferedWriter`, returning the underlying writer.
///
/// The internal buffer is flushed before returning the writer.
/// 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> {
}
impl<W: Writer> Writer for LineBufferedWriter<W> {
///
/// The internal buffer is flushed before returning the stream. Any leftover
/// data in the read buffer is lost.
///
/// 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;
let InternalBufferedWriter(w) = self.inner.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> {
}
impl<S: Stream> Buffer for BufferedStream<S> {
/// let mut w = MemWriter::new();
/// w.write(&[0, 1, 2]);
///
/// 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)]
/// ```
#[deprecated = "use the Vec<u8> Writer implementation directly"]
#[deriving(Clone)]
/// Unwraps this `MemWriter`, returning the underlying buffer
#[inline]
/// 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 {
}
impl Writer for MemWriter {
/// Unwraps this `MemReader`, returning the underlying buffer
#[inline]
/// 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 {
}
impl Reader for MemReader {
/// 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.
/// 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()
}
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()
/// Access the wrapped `std::path::Path` to the temporary directory.
pub fn path<'a>(&'a self) -> &'a Path {
self.path.as_ref().unwrap()
}
/// Consumes the `LimitReader`, returning the underlying `Reader`.
}
/// 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.
/// Returns the number of bytes that can be read before the `LimitReader`
/// will return EOF.
/// Consumes the `TeeReader`, returning the underlying `Reader` and
/// `Writer`.
/// 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)
}
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> {
}
impl<R: Reader, W: Writer> Reader for TeeReader<R, W> {
impl<A> Future<A> {
/// Gets the value from this future, forcing evaluation.
impl<A> Future<A> {
/// Gets the value from this future, forcing evaluation.
- pub fn unwrap(mut self) -> A {
+ pub fn into_inner(mut self) -> A {
self.get_ref();
let state = replace(&mut self.state, Evaluating);
match state {
self.get_ref();
let state = replace(&mut self.state, Evaluating);
match state {
+ /// Deprecated, use into_inner() instead
+ #[deprecated = "renamed to into_inner()"]
+ pub fn unwrap(self) -> A { self.into_inner() }
+
pub fn get_ref<'a>(&'a mut self) -> &'a A {
/*!
* Executes the future's closure and then returns a reference
pub fn get_ref<'a>(&'a mut self) -> &'a A {
/*!
* Executes the future's closure and then returns a reference
/// completes or panics. Equivalent to `.try_future(f).unwrap()`.
#[unstable = "Error type may change."]
pub fn try<T:Send>(self, f: proc():Send -> T) -> Result<T, Box<Any + Send>> {
/// completes or panics. Equivalent to `.try_future(f).unwrap()`.
#[unstable = "Error type may change."]
pub fn try<T:Send>(self, f: proc():Send -> T) -> Result<T, Box<Any + Send>> {
- self.try_future(f).unwrap()
+ self.try_future(f).into_inner()
let result_future = task.try_future(testfn);
let stdout = reader.read_to_end().unwrap().into_iter().collect();
let result_future = task.try_future(testfn);
let stdout = reader.read_to_end().unwrap().into_iter().collect();
- let task_result = result_future.unwrap();
+ let task_result = result_future.into_inner();
let test_result = calc_result(&desc, task_result.is_ok());
monitor_ch.send((desc.clone(), test_result, stdout));
})
let test_result = calc_result(&desc, task_result.is_ok());
monitor_ch.send((desc.clone(), test_result, stdout));
})