preinterpret

Macro preinterpret 

Source
preinterpret!() { /* proc-macro */ }
Expand description

Runs a simple interpeter over the token stream, allowing for variable assignment and substitution, and a toolkit of commands to simplify code generation.

Commands look like [!command! arguments as token stream here] and can be nested.

§Command cheat sheet

  • [!set! #foo = ...] set a variable to the provided token stream
  • #foo outputs the variable’s saved token stream
  • [!ident! ...] outputs an ident from parsing the concatenated token stream
  • [!ident_camel! ...] outputs an UpperCamelCased ident from parsing the concatenated token stream
  • [!ident_snake! ...] outputs a lower_snake_cased ident from parsing the concatenated token stream
  • [!ident_upper_snake! ...] outputs an UPPER_SNAKE_CASED ident from parsing the concatenated token stream
  • [!string! ...] outputs the concatenated token stream
  • [!literal! ..] outputs a literal from parsing the concatenated token stream
  • #[doc = [!string! "My documentation is for " #my_type "."]] can be used to create documentation strings

See the crate-level documentation for full details.