diff --git a/appmgr/src/util/mod.rs b/appmgr/src/util/mod.rs index ef178a9ce..cf962ed96 100644 --- a/appmgr/src/util/mod.rs +++ b/appmgr/src/util/mod.rs @@ -1031,17 +1031,21 @@ impl Future for NonDetachingJoinHandle { } } -pub struct GeneralGuard(Option); -impl GeneralGuard { +pub struct GeneralGuard T, T = ()>(Option); +impl T, T> GeneralGuard { pub fn new(f: F) -> Self { GeneralGuard(Some(f)) } + + pub fn drop(mut self) -> T { + self.0.take().unwrap()() + } } -impl Drop for GeneralGuard { +impl T, T> Drop for GeneralGuard { fn drop(&mut self) { if let Some(destroy) = self.0.take() { - destroy() + destroy(); } } }