azriel91

rust lazy macro

Apr 3rd, 2018
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.31 KB | None | 0 0
  1. // Declaring crate
  2. macro_rules some_macro {
  3.     if cfg!(test) {
  4.         panic!("boom");
  5.     } else {
  6.         panic!("bang");
  7.     }
  8. }
  9.  
  10. // Consuming crate
  11. // cargo test --release
  12. #[cfg(test)]
  13. mod test {
  14.     #[test]
  15.     fn abc() {
  16.         some_macro!(); // I want this to go boom, but it goes bang
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment