Skip to content

Instantly share code, notes, and snippets.

@anka-213
Forked from anonymous/playground.rs
Created April 14, 2016 17:04
Show Gist options
  • Save anka-213/7d2a946b6fe1d31b9cbd48c09e53bf0f to your computer and use it in GitHub Desktop.
Save anka-213/7d2a946b6fe1d31b9cbd48c09e53bf0f to your computer and use it in GitHub Desktop.
Shared via Rust Playground
#![feature(trace_macros)]
trace_macros!(true);
macro_rules! wrap {
($n:expr) => (wrap!(S($n)))
}
macro_rules! wrap_nocrash {
($($n:tt)*) => (wrap_nocrash!(S($($n)*)))
}
macro_rules! nest2 {
($($n:tt)*) => (id!($($n)*))
}
macro_rules! nest {
($n:expr) => (id_tt!($n))
}
macro_rules! id {
($n:expr) => ($n)
}
macro_rules! id_tt {
($($n:tt)*) => (id!($($n)*))
}
macro_rules! nest3 {
($n:expr) => (nest!(S($n)))
}
fn main() {
//wrap!(0); // Crashes
//wrap2!(0); // Doesn't crash
// nest! { S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(0))))))))))))))))))))))))) }; // Doesn't crash
//nest! { S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(0)))))))))))))))))))))))))) };
nest3! { S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(0))))))))))))))))))))))))) };
//id!{id! { S (S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(0)))))))))))))))))))))))))) ) }};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment