Skip to content

Commit 59ba55d

Browse files
committed
Auto merge of #25473 - doomrobo:patch-3, r=steveklabnik
Added `Deref` to the "Special Traits" section
2 parents bc6318d + d3ac395 commit 59ba55d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/doc/reference.md

+8
Original file line numberDiff line numberDiff line change
@@ -3622,6 +3622,14 @@ The `Sized` trait indicates that the size of this type is known at compile-time.
36223622
The `Drop` trait provides a destructor, to be run whenever a value of this type
36233623
is to be destroyed.
36243624

3625+
## The `Deref` trait
3626+
3627+
The `Deref<Target = U>` trait allows a type to implicitly implement all the methods
3628+
of the type `U`. When attempting to resolve a method call, the compiler will search
3629+
the top-level type for the implementation of the called method. If no such method is
3630+
found, `.deref()` is called and the compiler continues to search for the method
3631+
implementation in the returned type `U`.
3632+
36253633
# Memory model
36263634

36273635
A Rust program's memory consists of a static set of *items* and a *heap*.

0 commit comments

Comments
 (0)