Modify Rc/Arc language around mutability

There are a few exceptions to the rule that Arc/Rc are immutable. Rather
than dig into the details, add "generally" to hint at this difference,
as it's kind of a distraction at this point in the docs.

Additionally, Arc's docs were slightly different here generally, so add
in both the existing language and the exception.

Fixes #44105
This commit is contained in:
steveklabnik 2017-10-05 16:54:56 -04:00
parent 4531131bf3
commit 5e251b74eb
2 changed files with 5 additions and 3 deletions

View File

@ -52,8 +52,10 @@ const MAX_REFCOUNT: usize = (isize::MAX) as usize;
/// also destroyed. /// also destroyed.
/// ///
/// Shared references in Rust disallow mutation by default, and `Arc` is no /// Shared references in Rust disallow mutation by default, and `Arc` is no
/// exception. If you need to mutate through an `Arc`, use [`Mutex`][mutex], /// exception: you cannot generally obtain a mutable reference to something
/// [`RwLock`][rwlock], or one of the [`Atomic`][atomic] types. /// inside an `Arc`. If you need to mutate through an `Arc`, use
/// [`Mutex`][mutex], [`RwLock`][rwlock], or one of the [`Atomic`][atomic]
/// types.
/// ///
/// ## Thread Safety /// ## Thread Safety
/// ///

View File

@ -19,7 +19,7 @@
//! given value is destroyed, the pointed-to value is also destroyed. //! given value is destroyed, the pointed-to value is also destroyed.
//! //!
//! Shared references in Rust disallow mutation by default, and [`Rc`] //! Shared references in Rust disallow mutation by default, and [`Rc`]
//! is no exception: you cannot obtain a mutable reference to //! is no exception: you cannot generally obtain a mutable reference to
//! something inside an [`Rc`]. If you need mutability, put a [`Cell`] //! something inside an [`Rc`]. If you need mutability, put a [`Cell`]
//! or [`RefCell`] inside the [`Rc`]; see [an example of mutability //! or [`RefCell`] inside the [`Rc`]; see [an example of mutability
//! inside an Rc][mutability]. //! inside an Rc][mutability].