Function defer

pub fn defer<T, F>(thing: &mut T, deferred: F) -> impl DerefMut
where F: FnOnce(&mut T),
Expand description

Automatically calls a deferred function when the returned handle is dropped.