I am trying to use ?in a macro matching an arbitrary keyword:
macro_rules! foo {
(
pub fn $name:ident (
& $m : $( mut )? self
)
) => (
pub fn $name (
& $m self
) {}
)
}
struct Foo;
impl Foo {
foo!( pub fn bar(&mut self) );
foo!( pub fn baz(&self) );
}
fn main() {}
I tried a variety of syntax, but they all failed. How to do it?
source
share