Rust: Deref Trait

Опубликовано: 24 Ноябрь 2022
на канале: The Dev Method
8,622
302

#rust #traits #dereference

The Deref trait provides Rust with the info it needs to customize the deference * operator for you custom data types.

0:00 intro
1:14 Following the Pointer to the Value
4:16 Using Box Like a Reference
5:26 Defining Our Own Smart Pointer
6:37 Treating a Type Like a Reference by Implementing the Deref Trait
8:44 Implicit Deref Coercions with Functions and Methods
12:32 How Deref Coercion Interacts with Mutability

Links

Chapter 15 section 2
Treating Smart Pointers Like Regular References with the Deref Trait
https://doc.rust-lang.org/book/ch15-0...

Chapter 10
“Implementing a Trait on a Type”
https://doc.rust-lang.org/book/ch10-0...

Chapter 5
“Using Tuple Structs without Named Fields to Create Different Types”
https://doc.rust-lang.org/book/ch05-0...

Chapter 19
Advanced Traits
https://doc.rust-lang.org/book/ch19-0...

Twitter
@thedevmethod