1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2024-12-15 06:20:32 +02:00

Update drop.md (#246)

Adding speaker notes about more details when people might want to call
`drop`.

It is not about a `Drop` trait per-se, but if this is to be mentioned in
the course, this is a reasonable place.

---------

Co-authored-by: Martin Geisler <mgeisler@google.com>
Co-authored-by: Martin Geisler <martin@geisler.net>
This commit is contained in:
Igor Petruk 2023-09-19 12:29:53 +02:00 committed by GitHub
parent c5231fc38a
commit 0b8ec0ca3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -31,6 +31,10 @@ fn main() {
<details>
* `drop` is called automatically, but it can be called manually like in this example.
* If it was called manually, it won't be called at the end of the scope for the second time.
* Calling `drop` can be useful for objects that do some work on `drop`: releasing locks, closing files, etc.
Discussion points:
* Why doesn't `Drop::drop` take `self`?