macro_rules! tuple { ($($t:tt)*) => { ... }; }
Expand description
Generate a tuple from a list of expressions.
§Syntax
tuple!( [ Expr1 [; Count], Expr2 [; Count], ... ] )
[
and ]
only indicate the optional content but not that they need to be input.
Similarly, ...
indicates several repeated segments, rather than inputting ...
.
§Examples
use tuplez::{tuple, Unit};
let tup = tuple!(1, "hello", 3.14);
let tup2 = tuple!("world", 2;3, 9.8); // Repeat `2` three times
assert_eq!(tup2, tuple!("world", 2, 2, 2, 9.8));
let unit = tuple!();
assert_eq!(unit, Unit);
Remember that the tuple!
macro does not directly evaluate expressions, so:
use tuplez::tuple;
let mut x = 0;
assert_eq!(tuple!({x += 1; x}; 3), tuple!(1, 2, 3));