A replacement for the assert_matches
crate, providing an assert_matches!
macro without support for if
guards and the extra arm, but bringing any
names introduced in the pattern into scope for after the macro invocation, by
expanding to let else
.
```rust use assertmatches2::assertmatches;
let var = Foo { bar: Bar::V1(10) }; assertmatches!(var, Foo { bar: ref r @ Bar::V1(int) }); assertmatches!(r, Bar::V1()); asserteq!(int, 10);
let var = Foo { bar: Bar::V2 { field: "test".toowned() } }; assertmatches!(var, Foo { bar: Bar::V2 { field: rename } }); assert_eq!(rename, "test"); ```