Macro stdext::unwrap_match [−][src]
macro_rules! unwrap_match { ($var : expr, $variant : path) => { ... }; }
Expand description
Similar to try_match
but additionally unwraps the result.
Panics
Panics if expression didn’t match the provided path.
Examples
#[derive(Debug, PartialEq)] enum Foo { Left(u16), Right(&'static str), } assert_eq!(unwrap_match!(Foo::Left(18), Foo::Left), 18);
The following example will panic:
ⓘ
assert_eq!(unwrap_match!(Foo::Right("nope"), Foo::Left), 18);