Last active
September 10, 2023 07:06
-
-
Save iczero/19e978f252dc73041f51c296c6b8d8b6 to your computer and use it in GitHub Desktop.
crimes against Rust
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
#![feature(macro_metavar_expr)] | |
macro_rules! repeat_2 { | |
($($what:tt)*) => { | |
$($what)* | |
$($what)* | |
} | |
} | |
macro_rules! make_repeat_from { | |
($from:ident, $out:ident) => { | |
macro_rules! $out { | |
($$($$what:tt)*) => { | |
$from! { $$($$what)* } | |
$from! { $$($$what)* } | |
} | |
} | |
} | |
} | |
macro_rules! make_repeat { | |
($from:ident $out:ident $($rest:ident)*) => { | |
make_repeat_from! { $from, $out } | |
make_repeat! { $out $($rest)* } | |
}; | |
($last:ident) => {} | |
} | |
make_repeat! { | |
repeat_2 | |
repeat_4 | |
repeat_8 | |
repeat_16 | |
repeat_32 | |
repeat_64 | |
repeat_128 | |
repeat_256 | |
repeat_512 | |
repeat_1024 | |
/* uncomment to hang everything | |
repeat_2048 | |
repeat_4096 | |
repeat_8192 | |
repeat_16384 | |
repeat_32768 | |
repeat_65536 | |
*/ | |
} | |
fn main() { | |
let mut i = 0; | |
repeat_1024! { | |
println!("hello {}", i); | |
i += 1; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment