Trait core::ops::Drop
[−]
[src]
pub trait Drop {
fn drop(&mut self);
}The Drop`Drop` trait is used to run some code when a value goes out of scope. This
is sometimes called a 'destructor'.
Examples
A trivial implementation of Drop`Drop. The`. The drop`dropmethod is called when` method is called when _x`_xgoes out of scope, and therefore` goes
out of scope, and therefore main`mainprints` prints Dropping!`Dropping!`.
struct HasDrop; impl Drop for HasDrop { fn drop(&mut self) { println!("Dropping!"); } } fn main() { let _x = HasDrop; }
Required Methods
fn drop(&mut self)
The drop`drop` method, called when the value goes out of scope.