Rust 56 🦀 Cleanup Code Customization with the Drop Trait
Rust’s ownership rules free memory automatically when a value goes out of scope. That covers the common case, but not every resource is memory. A file handle must be closed, a lock must be released, a socket must be shut down, a temporary file must be deleted. The Drop trait is the mechanism that lets…