Say I'd like to write a macro that takes an identifier and defines a function with the ident as part of its name:
macro_rules! defun {
( $name:ident ) => {
fn fun_$name() { // This doesn't work, need to find a way
// to convert "foo" into "fun_foo"
// ...
}
}
}
defun!(foo);
Is this possible?
P.S. My actual use case is more like
macro_rules! tests {
( $( $name:ident ),* $(,)* ) => {
$(
#[test]
fn test_case_$name() {
// ...
}
)*
}
}
tests!{
fixture1,
fixture2,
}
for a bunch of integration tests.