diff --git a/shared/comm-lib/src/tools.rs b/shared/comm-lib/src/tools.rs --- a/shared/comm-lib/src/tools.rs +++ b/shared/comm-lib/src/tools.rs @@ -46,13 +46,17 @@ /// } /// } /// ``` -pub struct Defer<'s>(Option>); +pub struct Defer<'s>(Option>); impl<'s> Defer<'s> { - pub fn new(f: impl FnOnce() + 's) -> Self { + pub fn new(f: impl FnOnce() + 's + Send) -> Self { Self(Some(Box::new(f))) } + pub fn empty() -> Self { + Self(None) + } + /// Consumes the value, without calling the provided function /// /// # Example