Quasi-Quote
This is an alternative to quote that doesn't rely on proc-macro2.
It also uses a slightly different syntax that allows interposing control flow and quoted code.
How?
The basics are as follows: The QuoteExt trait contains the most immediately useful methods,
and the qq! macro converts its input tokens into a type that implements Quote (and thus QuoteExt).
A simple example:
use ;
For more details, refer to the crate documentation.
Why?
These are some possible motivations for using this crate:
- You want to write a procedural macro with minimal dependencies.
- You have read the source code of
quoteand/orproc-macro2and were rightly horrified. - You dislike having to do all control flow before invoking
quote::quote!.