hirun 0.1.16

A concurrent framework for asynchronous programming based on event-driven, non-blocking I/O mechanism
Documentation
pub struct Guard<F: FnOnce()> {
    action: Option<F>,
}

impl<F: FnOnce()> Guard<F> {
    pub fn new(action: F) -> Self {
        Self { action: Some(action) }
    }
    pub fn commit(self) {}
    pub fn dismiss(mut self) {
        let _ = self.action.take();
    }
}

impl<F: FnOnce()> Drop for Guard<F> {
    fn drop(&mut self) {
        if let Some(action) = self.action.take() {
            action()
        }
    }
}