[−][src]Macro matches2::assert_matches
Assert that an expression matches a refutable pattern.
Syntax: assert_matches!(
expression ,
pattern [ ,
error message ] )
If the pattern does not match, this macro panics with the given error message or a default one
that contains the pattern in it.
NB: The error message is passed through to panic! verbatim, so you can do assert_matches!(..., "{}", 2)
.
Examples
#[macro_use] extern crate matches2; fn main() { let data = [1, 2, 3]; assert_matches!(data.get(1), Some(_)); }