Skip to content

Instantly share code, notes, and snippets.

@hex13
Created May 8, 2021 15:19
Show Gist options
  • Save hex13/deede26abd35d8d5a636d1bf3e2904ae to your computer and use it in GitHub Desktop.
Save hex13/deede26abd35d8d5a636d1bf3e2904ae to your computer and use it in GitHub Desktop.
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