Where traditional object-oriented languages have destructors, Rust has the Drop trait, which consists of a single drop function that is called whenever a variable's lifetime has ended. By implementing it, you can perform whatever cleanup or advanced logging is necessary. You can also automatically free resources via RAII, as we're going to see in the next recipe.




















































