Crate qq

Crate qq 

Source
Expand description

§Quasi-Quote

qq is an alternative to quote, providing native proc_macro support and a different escaping syntax (see qq!).

It supports Rust 1.56 and above.

§Crate features

  • proc-macro (enabled by default): Enables support for the proc_macro crate. Functions behind this feature gate may panic if called from outside of a procedural macro.
  • proc-macro2: Enables support for the proc-macro2 crate.
  • preserve-proc-macro: Only has an effect when both proc-macro and proc-macro2 features are enabled. Changes some internals from only using proc-macro2 to using enums of it and regular proc-macro.
    This could be redundant, since proc-macro2 types are usually already enums of proc_macro types and fallback types, but proc-macro2 is up to some weird shenanigans like rustc-version-dependent API, nightly detection, and semver exemption per cfg, so this feature offers the option to trade a small bit of efficiency for the guarantee that code using proc_macro types will always go through proc_macro and never switch over to proc-macro2 because some other crate in the dependency tree depended on this crate and enabled the proc-macro2 feature.
  • rust-1-79: Implements Quote for &CStr to create a c-string literal. (Note that you can still create a c-string literal in earlier Rust versions using Literal::from_str; A Literal always implements Quote.)

Note that either proc-macro or proc-macro2 has to be enabled, otherwise this crate is useless (and doesn’t compile).

Re-exports§

pub extern crate proc_macro;

Re-exports§

pub use proc_macro2;proc-macro2

Macros§

qq
Convert written code to a type that implements Quote by emitting the tokens that make up the written code.

Structs§

QuoteBuilder
Helper type to make writing out deeply nested tuples for impl Quote easier.
QuoteIter
Quote adapter for iterators.
WithSpan
TokenAccumulator that attaches a given span to all accumulated tokens.

Enums§

QuoteEither
Quote adapter for match output.

Traits§

Quote
Main trait of this crate.
QuoteExt
Convenience methods for Quote.
TokenAccumulator
Something that can accumulate tokens.

Type Aliases§

Group
Wrapper for proc_macro::Group, proc_macro2::Group, or a lazily quoted value.
Ident
Wrapper for proc_macro::Ident, proc_macro2::Ident, or a lazily quoted value.
Literal
Wrapper for proc_macro::Literal, proc_macro2::Literal, or a lazily quoted value.
Punct
Wrapper for proc_macro::Punct, proc_macro2::Punct, or a lazily quoted value.