use std::mem; pub struct OnDrop(pub F) where F: FnMut() + Copy; impl OnDrop { pub fn forget(self) { mem::forget(self); } } impl Drop for OnDrop { fn drop(&mut self) { (self.0)(); } }