dynamic_tuple!() { /* proc-macro */ }
Expand description
A procedural macro to create a tuple with dynamic number of arguments.
This macro takes exactly two arguments, both of which should be valid Rust expressions that evaluate to integer types. The macro will expand to the tuple, including value of first argument repeated N times, where N is a value of second argument.
§Examples
Use the macro to sum two integers:
use easify_macros::dynamic_tuple;
let result = dynamic_tuple!(2, 1);
assert_eq!(result, (2, ));
use easify_macros::dynamic_tuple;
let result = dynamic_tuple!(5, 3);
assert_eq!(result, (5, 5, 5));
§Panics
The macro will cause arguments_number compile-time error if not exactly two arguments are provided.
// This will fail to compile
// let result = dynamic_tuple!(5);