RustThe Drop Trait - Destructors in Rust


Remarks

Using the Drop Trait does not mean that it will be run every time. While it will run when going out of scope or unwinding, it might not not always be the case, for example when mem::forget is called.

This is because a panic while unwinding causes the program to abort. It also might have been compiled with Abort on Panic switched on.

For more information check out the book: https://doc.rust-lang.org/book/drop.html