std::panic::take_hook - Rust
Description: API documentation for the Rust `take_hook` fn in crate `std`.
Keywords: rust, rustlang, rust-lang, take_hook

# 1.10.0[−][src]Function std::panic::take_hook

    pub fn take_hook() -> Box<dyn Fn(&PanicInfo) + Sync + Send + 'static>

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":

ⓘThis example panics

    use std::panic;

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

    let _ = panic::take_hook();

    panic!("Normal panic");

Run