macro_rules! assert_matches {
($expression:expr, $pattern:pat if $guard:expr, $($arg:tt)+) => { ... };
($expression:expr, $pattern:pat if $guard:expr $(,)?) => { ... };
($expression:expr, $pattern:pat, $($arg:tt)+) => { ... };
($expression:expr, $pattern:pat $(,)?) => { ... };
}Expand description
Asserts that an expression matches a given pattern.
This is a stable polyfill for assert_matches! that ensures 100% region coverage.
Unlike the crate or standard library macros, this implementation avoids generating
unreachable panic branches that llvm-cov flags as uncovered regions.
ยงExamples
use libcnb_test::assert_matches;
let result: Result<i32, String> = Ok(42);
// Simple pattern matching
assert_matches!(result, Ok(_));
// With guard
assert_matches!(result, Ok(x) if x > 40);
// With custom error message
assert_matches!(result, Ok(x) if x > 40, "value should be greater than 40");