macro_rules! matches syntax and expands to more syntax, before type checking. It does what a function cannot:
- take a variable number of arguments
- accept arguments of different types in the same position
- capture the source text of an expression (this is how
assert_eq!prints both sides)
macro_rules! metric {
($name:expr, $value:expr) => { format!("{}={}", $name, $value) };
}
