Skip to content

Improve src/trait/drop.md documentation #1908

@wowinter13

Description

@wowinter13

Hello, guys!
What do you think about adding a more thorough description with some custom drop logic, rather than just println!("> Dropping {}", self.name);?
There was a related issue: rust-lang/book#4181 (comment)

TLDR: my main idea is to provide something more obvious than just println!("Dropping CustomSmartPointer with data {}!", self.data);. For instance, when we are talking about files, the current book chapter states that "...lets you customize what happens when a value is about to go out of scope.", but it doesn't really show any customization behavior. So I thought it might be helpful for newcomers to see that drop() could be useful when working with fixtures, so you don't need to write a function fn clear_data() and call it manually after every test - you can just extend drop behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions