Small procedural macro crate for custom panic functions.
This crate provides a define_panic procedural macro, which transforms a given function into a panic handler.
No closures are allowed with this macro.
Usage
To define a custom panic handler, annotate a function with #[panic_handler] macro.
The function must adhere to the following signature:
fn _some_name_(info: &PanicInfo) -> !.
Examples
use define_panic;
!
Limitations
- This macro only accepts functions as input. Closures are not allowed.
- The panic handler function must diverge, i.e., it must return
!. - Ensure that the panic handler function is properly defined and handles panics safely to avoid undefined behavior.
See Also
core::panic::PanicInfo: Struct representing information about a panic.