Clarify and restrict when {Arc,Rc}::get_mut_unchecked is allowed.

This commit is contained in:
Zachary S 2022-09-02 01:34:34 -05:00
parent fd3bfb3551
commit 96650fc714
2 changed files with 10 additions and 8 deletions

View File

@ -1091,10 +1091,11 @@ pub fn get_mut(this: &mut Self) -> Option<&mut T> {
///
/// # Safety
///
/// Any other `Rc` or [`Weak`] pointers to the same allocation must not be dereferenced
/// for the duration of the returned borrow.
/// This is trivially the case if no such pointers exist,
/// for example immediately after `Rc::new`.
/// If any other `Rc` or [`Weak`] pointers to the same allocation exist, then
/// they must be must not be dereferenced or have active borrows for the duration
/// of the returned borrow, and their inner type must be exactly the same as the
/// inner type of this Rc (including lifetimes). This is trivially the case if no
/// such pointers exist, for example immediately after `Rc::new`.
///
/// # Examples
///

View File

@ -1630,10 +1630,11 @@ pub fn get_mut(this: &mut Self) -> Option<&mut T> {
///
/// # Safety
///
/// Any other `Arc` or [`Weak`] pointers to the same allocation must not be dereferenced
/// for the duration of the returned borrow.
/// This is trivially the case if no such pointers exist,
/// for example immediately after `Arc::new`.
/// If any other `Arc` or [`Weak`] pointers to the same allocation exist, then
/// they must be must not be dereferenced or have active borrows for the duration
/// of the returned borrow, and their inner type must be exactly the same as the
/// inner type of this Rc (including lifetimes). This is trivially the case if no
/// such pointers exist, for example immediately after `Arc::new`.
///
/// # Examples
///