macro_rules! is_variant { ( $variant: path ) => { ... }; }
Expand description
Matches if the asserted value’s variant matches the expected variant.
§Examples
If the enum’s variants are already imported one can write:
let ok: Result<i32, ()> = Ok(4);
assert_that!(&ok, is_variant!(Ok));
If not then the full path of the variant has to be used:
enum MyEnum { Foo, Bar(i32), Baz{x: i32} }
assert_that!(&MyEnum::Baz{x: 2}, is_variant!(MyEnum::Baz));