pub fn with_cleanup<TASK, T, E, CLEANUP, CT, CE>(
cleanup: CLEANUP,
task: TASK,
) -> Result<T, E>where
TASK: UnwindSafe + FnOnce() -> Result<T, E>,
CLEANUP: UnwindSafe + FnOnce() -> Result<CT, CE>,
E: Display,
CE: Display + Into<E>,Expand description
Perform task. On error or panic, perform cleanup and return the original
error, or continue to panic.
This is resilient to errors and panics in cleanup too: they will be
logged, but ultimately the errors and panics from task will be propagated.