pub struct Person {} // in Rust, destructors are implmented using the Drop trait impl Drop for Person { fn drop(&mut self) { println!("ciao"); } } // implement the drop function of the standard library pub fn drop(x: T) { // take ownership of an object // nothing here } // end of scope: automatic deallocation fn trigger_a_destructor() { let p = Person {}; // create an object } // end of scope: automatic deallocation (will print "ciao")