|
12 | 12 |
|
13 | 13 | //! Single-threaded reference-counting pointers. |
14 | 14 | //! |
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. |
19 | 19 | //! |
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 |
21 | 21 | //! exception. If you need to mutate through an `Rc`, use [`Cell`][cell] or |
22 | 22 | //! [`RefCell`][refcell]. |
23 | 23 | //! |
|
44 | 44 | //! functions][assoc], called using function-like syntax: |
45 | 45 | //! |
46 | 46 | //! ``` |
47 | | -//! # use std::rc::Rc; |
48 | | -//! # let my_rc = Rc::new(()); |
| 47 | +//! use std::rc::Rc; |
| 48 | +//! let my_rc = Rc::new(()); |
| 49 | +//! |
49 | 50 | //! Rc::downgrade(&my_rc); |
50 | 51 | //! ``` |
51 | 52 | //! |
@@ -294,10 +295,13 @@ impl<T> Rc<T> { |
294 | 295 |
|
295 | 296 | /// Returns the contained value, if the `Rc` has exactly one strong reference. |
296 | 297 | /// |
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. |
298 | 300 | /// |
299 | 301 | /// This will succeed even if there are outstanding weak references. |
300 | 302 | /// |
| 303 | + /// [result]: ../../std/result/enum.Result.html |
| 304 | + /// |
301 | 305 | /// # Examples |
302 | 306 | /// |
303 | 307 | /// ``` |
@@ -331,7 +335,11 @@ impl<T> Rc<T> { |
331 | 335 | } |
332 | 336 | } |
333 | 337 |
|
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 |
335 | 343 | /// |
336 | 344 | /// # Examples |
337 | 345 | /// |
@@ -582,8 +590,10 @@ impl<T: ?Sized> Drop for Rc<T> { |
582 | 590 | /// Drops the `Rc`. |
583 | 591 | /// |
584 | 592 | /// 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 |
587 | 597 | /// |
588 | 598 | /// # Examples |
589 | 599 | /// |
|
0 commit comments