Expand description

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 my_panic_macro::define_panic;

#[panic_handler]
fn my_panic_function(info: &PanicInfo) -> ! {
    // Custom panic handling logic
}

§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

§Reference

Attribute Macros§