Skip to content

Instantly share code, notes, and snippets.

@vmx
Last active January 5, 2020 23:02
Show Gist options
  • Save vmx/8344286 to your computer and use it in GitHub Desktop.
Save vmx/8344286 to your computer and use it in GitHub Desktop.
Rust Macro for assert for pattern matching
macro_rules! assert_match(
($given:expr , $expected:ident) => (
match $given {
$expected => {},
_ => fail!("assertion failed: no match (given: `{:?}`, expected: `{:s}`)",
$given, stringify!($expected))
}
);
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment