Skip to content

Instantly share code, notes, and snippets.

@arifd
Created May 23, 2023 13:27
Show Gist options
  • Save arifd/2df966902bd40c8c3e9ba17a95a168fd to your computer and use it in GitHub Desktop.
Save arifd/2df966902bd40c8c3e9ba17a95a168fd to your computer and use it in GitHub Desktop.
variable args
/// 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