mirror of
https://github.com/rust-lang/book.git
synced 2026-11-30 19:54:34 -06:00
Make section titles consistent and easier to scan
This commit is contained in:
+2
-2
@@ -82,8 +82,8 @@
|
||||
- [`Box<T>` Points to Data on the Heap and Has a Known Size](ch15-01-box.md)
|
||||
- [The `Deref` Trait Allows Access to the Data Through a Reference](ch15-02-deref.md)
|
||||
- [The `Drop` Trait Runs Code on Cleanup](ch15-03-drop.md)
|
||||
- [The Reference Counted Smart Pointer `Rc<T>`](ch15-04-rc.md)
|
||||
- [The Interior Mutability Pattern and `RefCell<T>`](ch15-05-interior-mutability.md)
|
||||
- [`Rc<T>`, the Reference Counted Smart Pointer](ch15-04-rc.md)
|
||||
- [`RefCell<T>` and the Interior Mutability Pattern](ch15-05-interior-mutability.md)
|
||||
- [Creating Reference Cycles and Leaking Memory is Safe](ch15-06-reference-cycles.md)
|
||||
|
||||
- [Concurrency](ch16-00-concurrency.md)
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
## The Reference Counted Smart Pointer `Rc<T>`
|
||||
## `Rc<T>`, the Reference Counted Smart Pointer
|
||||
|
||||
In the majority of cases, ownership is very clear: you know exactly which
|
||||
variable owns a given value. However, this isn't always the case; sometimes,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
## The Interior Mutability Pattern and `RefCell<T>`
|
||||
## `RefCell<T>` and the Interior Mutability Pattern
|
||||
|
||||
*Interior mutability* is a design pattern in Rust for allowing you to mutate
|
||||
data that's immutable. The interior mutability pattern involves using `unsafe`
|
||||
@@ -152,6 +152,8 @@ enforce them at runtime instead of compile time. You could choose to use
|
||||
production rather than during development). Also, checking the borrowing rules
|
||||
while your program is running has a performance penalty.
|
||||
|
||||
### Multiple Owners of Mutable Data by Combining `Rc<T>` and `RefCell<T>`
|
||||
|
||||
So why would we choose to make the tradeoffs that using `RefCell<T>` involves?
|
||||
Well, remember when we said that `Rc<T>` has to store immutable data? Given
|
||||
that `RefCell<T>` is immutable, but has interior mutability, we can combine
|
||||
|
||||
Reference in New Issue
Block a user