Skip to content

Commit 29d3e57

Browse files
author
Keegan McAllister
committed
Apply some Arc doc changes to Rc
1 parent 05b6d68 commit 29d3e57

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

src/liballoc/rc.rs

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212

1313
//! Single-threaded reference-counting pointers.
1414
//!
15-
//! The type [`Rc<T>`][rc] provides shared ownership of a value, allocated
16-
//! in the heap. Invoking [`clone`][clone] on `Rc` produces a new pointer
17-
//! to the same value in the heap. When the last `Rc` pointer to a given
18-
//! value is destroyed, the pointed-to value is also destroyed.
15+
//! The type [`Rc<T>`][rc] provides shared ownership of a value of type `T`,
16+
//! allocated in the heap. Invoking [`clone`][clone] on `Rc` produces a new
17+
//! pointer to the same value in the heap. When the last `Rc` pointer to a
18+
//! given value is destroyed, the pointed-to value is also destroyed.
1919
//!
20-
//! Shared pointers in Rust disallow mutation by default, and `Rc` is no
20+
//! Shared references in Rust disallow mutation by default, and `Rc` is no
2121
//! exception. If you need to mutate through an `Rc`, use [`Cell`][cell] or
2222
//! [`RefCell`][refcell].
2323
//!
@@ -44,8 +44,9 @@
4444
//! functions][assoc], called using function-like syntax:
4545
//!
4646
//! ```
47-
//! # use std::rc::Rc;
48-
//! # let my_rc = Rc::new(());
47+
//! use std::rc::Rc;
48+
//! let my_rc = Rc::new(());
49+
//!
4950
//! Rc::downgrade(&my_rc);
5051
//! ```
5152
//!
@@ -294,10 +295,13 @@ impl<T> Rc<T> {
294295

295296
/// Returns the contained value, if the `Rc` has exactly one strong reference.
296297
///
297-
/// Otherwise, an `Err` is returned with the same `Rc` that was passed in.
298+
/// Otherwise, an [`Err`][result] is returned with the same `Rc` that was
299+
/// passed in.
298300
///
299301
/// This will succeed even if there are outstanding weak references.
300302
///
303+
/// [result]: ../../std/result/enum.Result.html
304+
///
301305
/// # Examples
302306
///
303307
/// ```
@@ -331,7 +335,11 @@ impl<T> Rc<T> {
331335
}
332336
}
333337

334-
/// Checks whether `Rc::try_unwrap` would return `Ok`.
338+
/// Checks whether [`Rc::try_unwrap`][try_unwrap] would return
339+
/// [`Ok`][result].
340+
///
341+
/// [try_unwrap]: struct.Rc.html#method.try_unwrap
342+
/// [result]: ../../std/result/enum.Result.html
335343
///
336344
/// # Examples
337345
///
@@ -582,8 +590,10 @@ impl<T: ?Sized> Drop for Rc<T> {
582590
/// Drops the `Rc`.
583591
///
584592
/// This will decrement the strong reference count. If the strong reference
585-
/// count reaches zero then the only other references (if any) are `Weak`,
586-
/// so we `drop` the inner value.
593+
/// count reaches zero then the only other references (if any) are
594+
/// [`Weak`][weak], so we `drop` the inner value.
595+
///
596+
/// [weak]: struct.Weak.html
587597
///
588598
/// # Examples
589599
///

0 commit comments

Comments
 (0)