INNER CODE UNIT · Rust
new
pamburus/hl · crates/lifecycle/src/lib.rs:25
pub fn new(value: T, notify: F) -> Self {
Self {
inner: Some(value),
notify: Some(notify),
}
}
}
impl<T, F> Drop for DropNotifier<T, F>
where
F: FnOnce(),
{
fn drop(&mut self) {
self.inner.take(); // drops the inner value
if let Some(f) = self.notify.take() {
f();
}
}