SHARE
TWEET

Untitled

a guest May 15th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. macro_rules! not_12_macro {
  2.     ($n:ident) => {{
  3.         if $n != 12 {
  4.             print!("macro: {} is not 12 but is instead {}\n", stringify!($n), $n);
  5.         }
  6.     }};
  7. }
  8.  
  9. fn not_12(n: u64) {
  10.     if n != 12 {
  11.         print!("fn: {} is not 12 but is instead {}\n", stringify!(n), n);
  12.     }
  13. }
  14.  
  15. pub fn main() {
  16.     let val_from_main = 15;
  17.  
  18.     not_12_macro!(val_from_main); // macro: val_from_main is not 12 but is instead 15
  19.     not_12(val_from_main); // fn: n is not 12 but is instead 15
  20.  
  21. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top