assert_matches

Macro assert_matches 

Source
macro_rules! assert_matches {
    ($expression:expr, $pattern:pat if $guard:expr $(,)?) => { ... };
    ($expression:expr, $pattern:pat) => { ... };
    ($expression:expr, $pattern:pat if $guard:expr, $($message:tt)+) => { ... };
    ($expression:expr, $pattern:pat, $($message:tt)+) => { ... };
}
Expand description

Assert expression is Some.

  • If true, return ().

  • Otherwise, call panic! with a message and the values of the expressions with their debug representations.

§Examples

use assertables::*;

let a = 'a';
assert_matches!(a, 'a'..='z');

// This will panic
let a = 'a';
assert_matches!(a, 'b'..='z');
// assertion failed: `assert_matches!(a)`
// https://docs.rs/assertables/…/assertables/macro.assert_matches.html
//  args: `a, 'b'..='z'`

§Module macros