Rust The Drop Trait - Destructors in Rust

30% OFF - 9th Anniversary discount on Entity Framework Extensions until December 15 with code: ZZZANNIVERSARY9


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:

Got any Rust Question?