Last active
January 5, 2020 23:02
-
-
Save vmx/8344286 to your computer and use it in GitHub Desktop.
Rust Macro for assert for pattern matching
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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