Suppose I have an ident
input parameter named module_name
. How can I generate the value of the attribute through this parameter?
In simple terms, I want to generate something like this:
macro_rules! import_mod {
( $module_name:ident ) => {
// This does not work,
// but I want to generate the value of the feature attribute.
// #[cfg(feature = $module_name)]
pub mod $module_name;
}
}
import_mod!(module1);
// #[cfg(feature = "module1")]
// pub mod module1;