# matches::assert_matches - Rust
API documentation for the Rust `assert_matches` macro in crate `matches`.
Keywords: rust, rustlang, rust-lang, assert_matches

# [−] [src] Macro matches::assert_matches

    macro_rules! assert_matches {
        ($expression:expr, $($pattern:tt)+) => { ... };
    }

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(_));
    }