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
This commit is contained in:
commit
f6cb58caee
14 changed files with 84 additions and 24 deletions
|
|
@ -256,15 +256,19 @@ impl<T> RefCell<T> {
|
|||
}
|
||||
|
||||
/// 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);
|
||||
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
|
||||
|
|
@ -518,5 +522,9 @@ impl<T> UnsafeCell<T> {
|
|||
#[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() }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue