@@ -15,7 +15,7 @@ pub trait Drop {
|
||||
```
|
||||
|
||||
The `Drop` trait is a mechanism for you to define _additional_ cleanup logic for your types,
|
||||
beyond what the compiler does for you automatically.
|
||||
beyond what the compiler does for you automatically.\
|
||||
Whatever you put in the `drop` method will be executed when the value goes out of scope.
|
||||
|
||||
## `Drop` and `Copy`
|
||||
@@ -24,7 +24,7 @@ When talking about the `Copy` trait, we said that a type can't implement `Copy`
|
||||
manages additional resources beyond the `std::mem::size_of` bytes that it occupies in memory.
|
||||
|
||||
You might wonder: how does the compiler know if a type manages additional resources?
|
||||
That's right: `Drop` trait implementations!
|
||||
That's right: `Drop` trait implementations!\
|
||||
If your type has an explicit `Drop` implementation, the compiler will assume
|
||||
that your type has additional resources attached to it and won't allow you to implement `Copy`.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user