Expand description
Use-site metaprogramming inspired by staging
This crate lets you run code at compile time to produce the tokens other proc_macros will consume. It is also useful for ad-hoc in place code generation, and for making templates (like Jinja or Mustache for your code). It uses its own simple inner language based on handlers, variables, and a user chosen sigil. The stage separation model of Rust does impose some limitations on what this crate can do.
There are two common ways to use this crate. As an end user, it is most likely that you will use the do_with_in proc_macro directly. But if you want to make use of parts of the functionality in order to implement these features into your own proc_macro directly, or to implement your own handlers offering extended functionality in the staged language, you’ll end up (at this stage) using the reexports from do_with_in_base, most notably do_with_in_explicit2.
The base handler list is in genericDefaultHandlers.
Macros§
- do_
with_ in - This is the proc_macro most users of this crate will use.
Structs§
Enums§
Traits§
Functions§
- actually_
escape - actually_
unescape - arithmetic
Handler - Perform basic arithmetic calculations.
- array
Handler - Provides tools for working with arrays.
- assignment
Internal Handler - concat
Handler - Concatenate two or more values together into a string.
- concat
Handler Inner - do_
with_ in_ explicit - do_
with_ in_ explicit2 - The function used to actually run a stage.
- do_
with_ in_ internal - escape
- fnHandler
- forHandler
- generic
Default Handlers - This function generates the default handler set.
- handle
MkHandler Runner - ifHandler
- Conditionally execute one of two branches, depending on the result of a test expression.
- import
Handler - Import the contents of a file.
- internal
FnRunner - letHandler
- Create and assign variables. Does NOT interpolate during either definition or use.
- logic
Handler - Handle logic expressions with a nestable sublanguage
- marker
Handler - Embeds data in one invocation of
do_with_in!
in a way that can be used in other invocations. - mkHandler
- naive
Stringifier Handler - Return a string representation of a
do-with-in!
value. - quote
- In the lisp sense; renders its argument inert.
- run
- Evaluate block of code in place.
- runMarkers
Handler - Loads data into the environment from other invocations of
do_with_in!
. - string_
to_ ident Handler - Turn a string into a named identifier.
- unescape
- unquote
- In the lisp sense; renders its argument ert.
- varHandler
- Create and assign variables. DOES interpolate during both definition and use.
- with
Sigil Handler - Redefine which sigil to use within the scope of the handler.