Reputation: 321
I'm writing a macro:
macro_rules! foo {
($(print)?) => {
// run `println!("hello") if print is given
}
}
Which could be called as:
foo!()
which would do nothing
foo!(print)
which would print hello
How do I detect if print
was supplied? When I use a repetition operator I need to put a variable in. Is there some sort of empty variable I can use? ((print $print:empty)?
)
Upvotes: 2
Views: 432