Stabilize RefCell::try_borrow_unguarded
Servo has been using this since https://github.com/servo/servo/pull/23196 to add a runtime check to some unsafe code, as discussed in PR https://github.com/rust-lang/rust/pull/59211. Stabilizing would help do more of the same in libraries that also have users on Stable.
This commit is contained in:
parent
c84a7abf8b
commit
9fd4d48b5e
|
@ -1,7 +0,0 @@
|
||||||
# `borrow_state`
|
|
||||||
|
|
||||||
The tracking issue for this feature is: [#27733]
|
|
||||||
|
|
||||||
[#27733]: https://github.com/rust-lang/rust/issues/27733
|
|
||||||
|
|
||||||
------------------------
|
|
|
@ -969,7 +969,6 @@ impl<T: ?Sized> RefCell<T> {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// #![feature(borrow_state)]
|
|
||||||
/// use std::cell::RefCell;
|
/// use std::cell::RefCell;
|
||||||
///
|
///
|
||||||
/// let c = RefCell::new(5);
|
/// let c = RefCell::new(5);
|
||||||
|
@ -984,7 +983,7 @@ impl<T: ?Sized> RefCell<T> {
|
||||||
/// assert!(unsafe { c.try_borrow_unguarded() }.is_ok());
|
/// assert!(unsafe { c.try_borrow_unguarded() }.is_ok());
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
#[unstable(feature = "borrow_state", issue = "27733")]
|
#[stable(feature = "borrow_state", since = "1.37.0")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn try_borrow_unguarded(&self) -> Result<&T, BorrowError> {
|
pub unsafe fn try_borrow_unguarded(&self) -> Result<&T, BorrowError> {
|
||||||
if !is_writing(self.borrow.get()) {
|
if !is_writing(self.borrow.get()) {
|
||||||
|
|
Loading…
Reference in New Issue