▲ | codedokode 4 days ago | ||||||||||||||||
That's the destructor function, that is written by you and called by Rust before actually destroying something. The function that you want to look at is [1]. If you read the docs at your link it even says: > This method is called implicitly when the value goes out of scope, and cannot be called explicitly (this is compiler error E0040). > However, the mem::drop function in the prelude can be used to call the argument’s Drop implementation. By the way the implementation of the function drop is just an empty function [2]; that's enough as local variables are destroyed on function return. Mutable reference is a "borrow" which means you take a value from an owner and promise to return it back, and you cannot destroy a thing that you must return. | |||||||||||||||||
▲ | steveklabnik 4 days ago | parent [-] | ||||||||||||||||
The drop function being talked about here is the one I pointed to, not the one you pointed to. The Drop trait is built into the language (as a lang item), std::mem::drop is just a regular old function. | |||||||||||||||||
|