replace placeholder regexp. alternate implementation of Ranting during compile time create a HashMap that add a vec to the struct. During compilation build an init function that populates a vec for each unique placeholder imputation difficult because the path of the define site is required. Maybe via https://doc.rust-lang.org/std/any/fn.type_name_of_val.html this requires per struct one subject, and the struct name as name, same as enum in a way. // see https://github.com/rust-lang/rust/issues/44034: // https://github.com/sam0x17/macro_state #[proc_macro_derive(Foo)] pub fn foo(input: TokenStream) -> TokenStream { ... } #[proc_macro_derive(Bar, depends_on(Foo))] pub fn bar(input: TokenStream) -> TokenStream { ... } ///// derive with attribute subject for name and enum. Every instance of this struct/enum will have this subject, and structs their struct name, enums the variant name. nope, impossible