Expand description
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 (except for 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);Macros§
- const_
panic_ msg - Declare a const PanicMsg with an
&'static strmessage.
Structs§
- Assertion
- An assert function with a message for runtime assertions.
- Panic
Msg - A message for runtime panics. When one of the methods is called on it, the given message is used as the output for the panic.
Traits§
- Into
Option - Used to convert Result into Option, or keep Option as it is.