mirror of
https://github.com/darkicewolf50/RustBrock.git
synced 2025-07-07 03:27:13 -06:00
finihed ch15.3
This commit is contained in:
@ -41,7 +41,7 @@ Unlike an ordinary struct, smart pointers implements the `Deref` and `Drop` trai
|
||||
|
||||
The `Deref` trait allows an instance of the smart pointer struct to behave like a reference so you can write your code to with either references or smart pointers. [Section Link Here](./Deref%20Trait.md)
|
||||
|
||||
The `Drop` trait allows you to customize the code that is run when an instance of the smart pointer goes out of scope.
|
||||
The `Drop` trait allows you to customize the code that is run when an instance of the smart pointer goes out of scope. [Section Link Here](./Drop%20Trait.md)
|
||||
|
||||
We will go over both traits and demonstrate why they are improtant to smart pointers.
|
||||
|
||||
@ -51,7 +51,7 @@ Many libraries have thier own smart pointers, and you can even write your own.
|
||||
|
||||
The ones we will cover are the most common smart pointers in the std library:
|
||||
- [`Box<T>` for allocating values on the heap](./Using%20Box%20on%20the%20Heap.md)
|
||||
- `Rc<T>`, a reference counting type that enables multiple ownership
|
||||
- `Rc<T>`, a reference counting type that enables multiple ownership [Section Link Here](./Reference%20Counter%20Smart%20Pointer.md)
|
||||
- `Ref<T>` and `RefMut<T>` this is accessed through `RefCell<T>`, a type that enforces the borrowing rules at runtime instead of compile time
|
||||
|
||||
In additon we will also cover *interior mutability* patter where an immutable tpye exposes an API for mutating an interior value.
|
||||
|
Reference in New Issue
Block a user