Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. macro_rules! assert_match {
  2. ($e:expr, $p:pat) => {
  3. match $e {
  4. $p => (),
  5. e => panic!("{:?} does not match {}", e, stringify!($p)),
  6. }
  7. };
  8. }
  9.  
  10. #[derive(Debug)]
  11. struct Value { num: i32 }
  12.  
  13.  
  14. fn main() {
  15. let actual_value = Value { num: 2 };
  16. let expected_num = 1;
  17. assert_match!(actual_value, Value { num: expected_num });
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement