Open
Description
I'm tinkering a bit with procedural macros and encountered a problem that can be solved by keeping state in between proc macro invocations.
Example from my real application: assume my proc-macro
crate exposes two macros: config! {}
and do_it {}
. The user of my lib is supposed to call config! {}
only once, but may call do_it! {}
multiple times. But do_it!{}
needs data from the config!{}
invocation.
Another example: we want to write a macro_unique_id!()
macro returning a u64
by counting internally.
How am I supposed to solve those problems? I know that somewhat-global state is usually bad. But I do see applications for crate-local state for proc macros.