Created
May 8, 2021 15:19
-
-
Save hex13/deede26abd35d8d5a636d1bf3e2904ae to your computer and use it in GitHub Desktop.
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! foo { | |
($a: literal ) => { | |
$a | |
}; | |
($op:tt $a:literal $b:tt) => { | |
foo!($op ($a) $b) | |
}; | |
($op:tt $a:tt $b:literal) => { | |
foo!($op $a ($b)) | |
}; | |
($op:tt $a:tt $b:tt) => { | |
foo!$a $op foo!$b | |
}; | |
} | |
fn main() { | |
let a = foo!(5); | |
let a = foo!( | |
* (+ (+ 1 1) (* 2 3)) 4 | |
); | |
println!("kotek = {}", a); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment