Is it possible to declare variables procedurally using Rust macros?

Yes however this is only available as a nightly-only experimental API which may be removed. You can pass arbitrary identifier into a macro and yes, you can concatenate identifiers into a new identifier using concat_idents!() macro: #![feature(concat_idents)] macro_rules! test { ($x:ident) => ({ let z = concat_idents!(hello_, $x); z(); }) } fn hello_world() { } … Read more

Generating documentation in macros

It is possible to capture doc comments in macro invocations. It is not widely-known, but Rust documentation is actually represented as a special kind of attribute on an item. For example: /// Some documentation comment pub fn function() {} // is equivalent to #[doc=”Some documentation comment”] pub fn function() {} And it is possible to … Read more