1 2 3 4 5 6 7 8 9 10 11 12
pub trait Disposable: Send + 'static { fn dispose(self: Box<Self>); } impl<F> Disposable for F where F: FnOnce() + Send + 'static, { fn dispose(self: Box<Self>) { (*self)() } }