Function std::panic::take_hook

1.10.0 · source · []
pub fn take_hook() -> Box<dyn Fn(&PanicInfo<'_>) + Sync + Send + 'static>Notable traits for Box<F, A>impl<F, A> Future for Box<F, A>where
    F: Future + Unpin + ?Sized,
    A: Allocator + 'static,
type Output = <F as Future>::Output;impl<I, A> Iterator for Box<I, A>where
    I: Iterator + ?Sized,
    A: Allocator,
type Item = <I as Iterator>::Item;impl<R: Read + ?Sized> Read for Box<R>impl<W: Write + ?Sized> Write for Box<W>
Expand description

Unregisters the current panic hook, returning it.

See also the function set_hook.

If no custom hook is registered, the default hook will be returned.

Panics

Panics if called from a panicking thread.

Examples

The following will print “Normal panic”:

use std::panic;

panic::set_hook(Box::new(|_| {
    println!("Custom panic hook");
}));

let _ = panic::take_hook();

panic!("Normal panic");
Run