Expand description
This crate contains two proc macros relating to asserting, under penalty of panic, that expressions match patterns.
coerce_pattern!matches an expression to a target pattern and evaluates to an expression of the inner variables from the pattern, panicking if the pattern doesn’t matchassert_pattern!matches an expression to a target and panics if the pattern doesn’t match.
To use them, run the following command in your project directory.
cargo add coerce_patternThen, you can use the macros using
use coerce_pattern::{coerce_pattern, assert_pattern};See below for detailed documentation on the macros.
Macros§
- assert_
pattern - Asserts that an expression matches a pattern, like a
generalized
assert!(result.is_ok()). - coerce_
pattern - Coerces an expression into a pattern, like a generalized unwrap.