panicmsg

Crates.iopanicmsg
lib.rspanicmsg
version1.3.0
created_at2025-01-31 13:39:04.232434+00
updated_at2025-02-15 05:11:41.256964+00
descriptionA library for simplyifying common panic messages.
homepage
repositoryhttps://github.com/ErisianArchitect/panicmsg
max_upload_size
id1537534
size15,231
Null (ErisianArchitect)

documentation

https://docs.rs/panicmsg

README

This crate provides reusable error messages (PanicMsg) for use with panics, assertions (assert, assert_eq, assert_ne), and expect. It also includes debug versions of each of these methods (besides expect).

Simply declare a PanicMsg:

const EXAMPLE_PANIC: PanicMsg = PanicMsg::new("This is an example panic message.");

Then use it like this:

EXAMPLE_PANIC.panic();
// ...
EXAMPLE_PANIC.panic_if(left >= right);
// ...
EXAMPLE_PANIC.assert(left < right);
// ...
EXAMPLE_PANIC.assert_eq(left, right);
// ...
EXAMPLE_PANIC.assert_ne(left, right);
// ...
EXAMPLE_PANIC.expect(option);
// ...
EXAMPLE_PANIC.expect(result);
// ...
EXAMPLE_PANIC.debug_panic();
// ...
EXAMPLE_PANIC.debug_panic_if(left >= right);
// ...
EXAMPLE_PANIC.debug_assert(left < right);
// ...
EXAMPLE_PANIC.debug_assert_eq(left, right);
// ...
EXAMPLE_PANIC.debug_assert_ne(left, right);
Commit count: 38

cargo fmt