W3cubDocs

/Rust

Function std::panic::take_hook

ⓘImportant traits for Box<I>
impl<I> Iterator for Box<I> where
    I: Iterator + ?Sized, 
    type Item = <I as Iterator>::Item;
impl<R: Read + ?Sized> Read for Box<R>
impl<W: Write + ?Sized> Write for Box<W>
pub fn take_hook() -> Box<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":

use std::panic;

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

let _ = panic::take_hook();

panic!("Normal panic");

© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/std/panic/fn.take_hook.html