Advertisement
Guest User

Untitled

a guest
May 15th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement