Macro matches::assert_matches
source · macro_rules! assert_matches {
($expression:expr, $($pattern:tt)+) => { ... };
}
Expand description
Assert that an expression matches a refutable pattern.
Syntax: assert_matches!(
expression ,
pattern )
Panic with a message that shows the expression if it does not match the pattern.
Examples
#[macro_use]
extern crate matches;
fn main() {
let data = [1, 2, 3];
assert_matches!(data.get(1), Some(_));
}