struct ScopeValue_<T>(T);
pub trait ScopeValueTrait_ { }
impl<T> ScopeValueTrait_ for ScopeValue_<T> { }
#[allow(dead_code)]
pub struct ScopeValue(Box<dyn ScopeValueTrait_>);
pub fn scope_any<T: 'static>(value: T) -> ScopeValue {
return ScopeValue(Box::new(ScopeValue_(value)));
}
struct Defer<F: 'static + FnOnce() -> ()>(Option<F>);
impl<F: 'static + FnOnce() -> ()> Drop for Defer<F> {
fn drop(&mut self) {
(self.0.take().unwrap())();
}
}
pub fn defer<F: 'static + FnOnce() -> ()>(f: F) -> ScopeValue {
return scope_any(Defer(Some(f)));
}