Is there anyway to return a different value based on the optional presence of an argument to macro_rules? For instance, I want an additional comma separating id
from label
but only if label
is defined. I can achieve this with separate rules, but is there a more concise way?:
macro_rules! options {
($table:tt, $id:tt) => (concat!("select distinct ", $id, " from ", $table, ";"));
($table:tt, $id:tt, $label:tt) => (concat!("select distinct ", $id, ", ", $label, " from ", $table, ";"))
}