Created
May 23, 2023 13:27
-
-
Save arifd/2df966902bd40c8c3e9ba17a95a168fd to your computer and use it in GitHub Desktop.
variable args
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
/// creates a nested tuple from the given args | |
/// ``` | |
/// assert_eq!( | |
/// vararg!("a", 15, true, 10.0), | |
/// ("a", (15, (true, (10.0, ())))) | |
/// ) | |
macro_rules! vararg { | |
($first:expr $(, $rest:expr)* $(,)?) => { | |
($first, vararg!( $($rest),* ) ) | |
}; | |
() => { () }; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment