install_with_cleanup

Function install_with_cleanup 

Source
pub fn install_with_cleanup<F>(cleanup: F)
where F: Fn() + Send + Sync + 'static,
Expand description

Install a panic handler with a custom cleanup function

The cleanup function will be called before the terminal is restored. This is useful for saving application state or performing other cleanup.

§Safety

The cleanup function must be thread-safe as it may be called from any thread.

§Example

use hojicha_runtime::panic_handler;

panic_handler::install_with_cleanup(|| {
    // Save application state, close files, etc.
    eprintln!("Saving application state before exit...");
});
// ... run your TUI application