Skip to content

Commit 5e251b7

Browse files
committed
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
1 parent 4531131 commit 5e251b7

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/liballoc/arc.rs

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

src/liballoc/rc.rs

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

0 commit comments

Comments
 (0)