@@ -765,10 +765,14 @@ impl<T> RefCell<T> {
765
765
}
766
766
767
767
impl < T : ?Sized > RefCell < T > {
768
- /// Query the current state of this `RefCell`
768
+ /// Queries the current state of this `RefCell`.
769
769
///
770
- /// The returned value can be dispatched on to determine if a call to
771
- /// `borrow` or `borrow_mut` would succeed.
770
+ /// A return value of `BorrowState::Writing` signals that this `RefCell`
771
+ /// is currently mutably borrowed, while `BorrowState::Reading` signals
772
+ /// that it is immutably borrowed.
773
+ ///
774
+ /// This is mostly useful in rare use cases with `RefCell::as_ptr` to
775
+ /// access the data without changing its borrow state, use with care.
772
776
///
773
777
/// # Examples
774
778
///
@@ -780,9 +784,9 @@ impl<T: ?Sized> RefCell<T> {
780
784
/// let c = RefCell::new(5);
781
785
///
782
786
/// match c.borrow_state() {
783
- /// BorrowState::Writing => println!("Cannot be borrowed"),
784
- /// BorrowState::Reading => println!("Cannot be borrowed mutably "),
785
- /// BorrowState::Unused => println!("Can be borrowed (mutably as well) "),
787
+ /// BorrowState::Writing => println!("currently borrowed mutably "),
788
+ /// BorrowState::Reading => println!("currently borrowed immutably "),
789
+ /// BorrowState::Unused => println!("not borrowed"),
786
790
/// }
787
791
/// ```
788
792
#[ unstable( feature = "borrow_state" , issue = "27733" ) ]
0 commit comments