Macro assert_matches::assert_matches
[−]
[src]
macro_rules! assert_matches { ( $e:expr , $pat:pat ) => { ... }; ( $e:expr , $pat:pat if $cond:expr ) => { ... }; ( $e:expr , $pat:pat , $($arg:tt)* ) => { ... }; ( $e:expr , $pat:pat if $cond:expr , $($arg:tt)* ) => { ... }; }
Asserts that an expression matches a given pattern, with an optional guard expression.
#[macro_use] extern crate assert_matches; #[derive(Debug)] enum Foo { A(i32), B(i32), } let a = Foo::A(1); assert_matches!(a, Foo::A(_)); assert_matches!(a, Foo::A(i) if i > 0);