Code example in chapter 17.2 has the following macro defined:
macro_rules! assert_equal_len {
// The `tt` (token tree) designator is used for
// operators and tokens.
($a:expr, $b:expr, $func:ident, $op:tt) => {
assert!($a.len() == $b.len(),
"{:?}: dimension mismatch: {:?} {:?} {:?}",
stringify!($func),
($a.len(),),
stringify!($op),
($b.len(),));
};
}
It is unclear why $a.len() and $b.len() are wrapped in parentheses with a trailing comma inside after the expression - looks like it could mean multiple instances (or lack) of an expression, but the context does not seem to allow for that. What is the purpose of that syntax?
Code example in chapter 17.2 has the following macro defined:
It is unclear why
$a.len()and$b.len()are wrapped in parentheses with a trailing comma inside after the expression - looks like it could mean multiple instances (or lack) of an expression, but the context does not seem to allow for that. What is the purpose of that syntax?