Cleaning up after test failure

Would setting a panic hook work in this case?

std::panic::set_hook(Box::new(|_| {
    cleanup();
    let _ = std::panic::take_hook();
}));
1 Like