Created
September 22, 2020 01:48
-
-
Save mrkishi/bffb145c3a4be6e2ca2911e7198acdb6 to your computer and use it in GitHub Desktop.
macro_rules! count
This file contains 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! count { | |
() => { 0 }; | |
($($half:tt $_:tt)*) => { count!($($half)*) * 2 }; | |
($one:tt $($half:tt $_:tt)*) => { count!($($half)*) * 2 + 1 }; | |
} | |
const TOTAL: usize = count!(+++++++); | |
pub fn main() { | |
println!("{}", TOTAL); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment