是否可以构建一个不输出任何内容但存储状态以构建列表的宏,然后再构建一个实际使用该数据的第二个宏?
例如:
trait SomeTrait {}
#[derive(mark)]
struct Person {}
impl SomeTrait for Person {}
#[derive(mark)]
struct Item {}
impl SomeTrait for Item {}
#[derive(mark)]
struct Object {}
impl SomeTrait for Object {}
create_mapper! // this then outputs the below function
//assuming for the fact that data is loaded correctly before this macro is used
fn select_item(kind: String) -> impl SomeTrait {
match kind {
"person" => Person,
"item" => Item,
"object" => Object,
}
}