@@ -460,20 +460,6 @@ pub struct RefCell<T: ?Sized> {
460460 value : UnsafeCell < T > ,
461461}
462462
463- /// An enumeration of values returned from the `state` method on a `RefCell<T>`.
464- #[ derive( Copy , Clone , PartialEq , Eq , Debug ) ]
465- #[ unstable( feature = "borrow_state" , issue = "27733" ) ]
466- #[ rustc_deprecated( since = "1.15.0" , reason = "use `try_borrow` instead" ) ]
467- #[ allow( deprecated) ]
468- pub enum BorrowState {
469- /// The cell is currently being read, there is at least one active `borrow`.
470- Reading ,
471- /// The cell is currently being written to, there is an active `borrow_mut`.
472- Writing ,
473- /// There are no outstanding borrows on this cell.
474- Unused ,
475- }
476-
477463/// An error returned by [`RefCell::try_borrow`](struct.RefCell.html#method.try_borrow).
478464#[ stable( feature = "try_borrow" , since = "1.13.0" ) ]
479465pub struct BorrowError {
@@ -562,38 +548,6 @@ impl<T> RefCell<T> {
562548}
563549
564550impl < T : ?Sized > RefCell < T > {
565- /// Query the current state of this `RefCell`
566- ///
567- /// The returned value can be dispatched on to determine if a call to
568- /// `borrow` or `borrow_mut` would succeed.
569- ///
570- /// # Examples
571- ///
572- /// ```
573- /// #![feature(borrow_state)]
574- ///
575- /// use std::cell::{BorrowState, RefCell};
576- ///
577- /// let c = RefCell::new(5);
578- ///
579- /// match c.borrow_state() {
580- /// BorrowState::Writing => println!("Cannot be borrowed"),
581- /// BorrowState::Reading => println!("Cannot be borrowed mutably"),
582- /// BorrowState::Unused => println!("Can be borrowed (mutably as well)"),
583- /// }
584- /// ```
585- #[ unstable( feature = "borrow_state" , issue = "27733" ) ]
586- #[ rustc_deprecated( since = "1.15.0" , reason = "use `try_borrow` instead" ) ]
587- #[ allow( deprecated) ]
588- #[ inline]
589- pub fn borrow_state ( & self ) -> BorrowState {
590- match self . borrow . get ( ) {
591- WRITING => BorrowState :: Writing ,
592- UNUSED => BorrowState :: Unused ,
593- _ => BorrowState :: Reading ,
594- }
595- }
596-
597551 /// Immutably borrows the wrapped value.
598552 ///
599553 /// The borrow lasts until the returned `Ref` exits scope. Multiple
0 commit comments