panic-custom-proc-macros 0.1.0

Small panicking macro crate that allows to easily set the behavior of panicking for embedded or regular no_std binaries.
Documentation
  • Coverage
  • 100%
    2 out of 2 items documented2 out of 2 items with examples
  • Size
  • Source code size: 6.6 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 285.48 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 4s Average build duration of successful builds.
  • all releases: 4s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • not-forest/panic-custom
    2 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • not-forest

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