Rust 1.28.0-nightly
86a8f1a63

# Drop

There is a new edition of the book and this is an old link.

> `Drop` lets us customize what happens when a value is about to go out of scope.

    struct CustomSmartPointer {
        data: String,
    }

    impl Drop for CustomSmartPointer {
        fn drop(&mut self) {
            println!("Dropping CustomSmartPointer with data `{}`!", self.data);
        }
    }

    fn main() {
        let c = CustomSmartPointer { data: String::from("my stuff") };
        let d = CustomSmartPointer { data: String::from("other stuff") };
        println!("CustomSmartPointers created.");
    }Run

Here are the relevant sections in the new and old books:

- In the second edition: Ch 15.03 — The `Drop` Trait Runs Code on Cleanup
- In the first edition: Ch 3.20 — Drop