File tree 5 files changed +16
-6
lines changed
5 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -1156,7 +1156,9 @@ impl<T: ?Sized> RefCell<T> {
1156
1156
/// Since this method borrows `RefCell` mutably, it is statically guaranteed
1157
1157
/// that no borrows to the underlying data exist. The dynamic checks inherent
1158
1158
/// in [`borrow_mut`] and most other methods of `RefCell` are therefore
1159
- /// unnecessary.
1159
+ /// unnecessary. Note that this method does not reset the borrowing state if borrows were previously leaked
1160
+ /// (e.g., via [`forget()`] on a [`Ref`] or [`RefMut`]). For that purpose,
1161
+ /// consider using the unstable [`undo_leak`] method.
1160
1162
///
1161
1163
/// This method can only be called if `RefCell` can be mutably borrowed,
1162
1164
/// which in general is only the case directly after the `RefCell` has
@@ -1167,6 +1169,8 @@ impl<T: ?Sized> RefCell<T> {
1167
1169
/// Use [`borrow_mut`] to get mutable access to the underlying data then.
1168
1170
///
1169
1171
/// [`borrow_mut`]: RefCell::borrow_mut()
1172
+ /// [`forget()`]: mem::forget
1173
+ /// [`undo_leak`]: RefCell::undo_leak()
1170
1174
///
1171
1175
/// # Examples
1172
1176
///
Original file line number Diff line number Diff line change @@ -427,7 +427,7 @@ pub unsafe trait CloneToUninit {
427
427
/// read or dropped, because even if it was previously valid, it may have been partially
428
428
/// overwritten.
429
429
///
430
- /// The caller may wish to to take care to deallocate the allocation pointed to by `dest`,
430
+ /// The caller may wish to take care to deallocate the allocation pointed to by `dest`,
431
431
/// if applicable, to avoid a memory leak (but this is not a requirement).
432
432
///
433
433
/// Implementors should avoid leaking values by, upon unwinding, dropping all component values
Original file line number Diff line number Diff line change @@ -99,8 +99,8 @@ macro_rules! i8_xe_bytes_doc {
99
99
100
100
**Note**: This function is meaningless on `i8`. Byte order does not exist as a
101
101
concept for byte-sized integers. This function is only provided in symmetry
102
- with larger integer types. You can cast from and to `u8` using `as i8` and `as
103
- u8` .
102
+ with larger integer types. You can cast from and to `u8` using
103
+ [`cast_signed`](u8::cast_signed) and [`cast_unsigned`](Self::cast_unsigned) .
104
104
105
105
"
106
106
} ;
Original file line number Diff line number Diff line change @@ -582,7 +582,9 @@ impl<T: ?Sized> Mutex<T> {
582
582
/// Returns a mutable reference to the underlying data.
583
583
///
584
584
/// Since this call borrows the `Mutex` mutably, no actual locking needs to
585
- /// take place -- the mutable borrow statically guarantees no locks exist.
585
+ /// take place -- the mutable borrow statically guarantees no new locks can be acquired
586
+ /// while this reference exists. Note that this method does not clear any previous abandoned locks
587
+ /// (e.g., via [`forget()`] on a [`MutexGuard`]).
586
588
///
587
589
/// # Errors
588
590
///
@@ -599,6 +601,8 @@ impl<T: ?Sized> Mutex<T> {
599
601
/// *mutex.get_mut().unwrap() = 10;
600
602
/// assert_eq!(*mutex.lock().unwrap(), 10);
601
603
/// ```
604
+ ///
605
+ /// [`forget()`]: mem::forget
602
606
#[ stable( feature = "mutex_get_mut" , since = "1.6.0" ) ]
603
607
pub fn get_mut ( & mut self ) -> LockResult < & mut T > {
604
608
let data = self . data . get_mut ( ) ;
Original file line number Diff line number Diff line change @@ -608,7 +608,9 @@ impl<T: ?Sized> RwLock<T> {
608
608
/// Returns a mutable reference to the underlying data.
609
609
///
610
610
/// Since this call borrows the `RwLock` mutably, no actual locking needs to
611
- /// take place -- the mutable borrow statically guarantees no locks exist.
611
+ /// take place -- the mutable borrow statically guarantees no new locks can be acquired
612
+ /// while this reference exists. Note that this method does not clear any previously abandoned locks
613
+ /// (e.g., via [`forget()`] on a [`RwLockReadGuard`] or [`RwLockWriteGuard`]).
612
614
///
613
615
/// # Errors
614
616
///
You can’t perform that action at this time.
0 commit comments