rx_rust/disposable/
callback_disposal.rs

1use crate::disposable::Disposable;
2
3/// A disposal that calls a callback when disposed.
4pub struct CallbackDisposal<F: FnOnce()>(F);
5
6impl<F: FnOnce()> CallbackDisposal<F> {
7    pub fn new(callback: F) -> Self {
8        Self(callback)
9    }
10}
11impl<F: FnOnce()> Disposable for CallbackDisposal<F> {
12    fn dispose(self) {
13        self.0();
14    }
15}