Is it possible to build a macro that doesn't output anything but instead for example stores state to build up a list and then a second macro that will then actually use that data and output some result?
For example:
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,
}
}