Quote
quote is a Rust crate and macro for constructing Rust token streams from quasi-quoted syntax.
Write Powerful Rust Macros
quote is a Rust library and macro for generating source-token streams from interpolated syntax.
- How it is used
- Generates output TokenStreams for Rust procedural macros, including derive, attribute, and builder macros.
- How deep it goes
- Explains interpolation, repeated field output, TokenStream conversion, testing, and debugging, while deferring compiler token-processing details.
- Examples
- Uses empty macro output, public struct fields, quoted builder expectations, and a generated builder with build and builder methods.
- What you can do after
- Build it from scratch by interpolating parsed Rust syntax into generated TokenStreams and testing the resulting code.
Idiomatic Rust
quote is a Rust library that generates Rust source code from syntax-like interpolation constructs.
- How it is used
- Generates Rust source code within procedural macros through syntax-like interpolation.
- How deep it goes
- Demonstrates interpolation and token stream conversion in a derive macro, but does not explore more elaborate macro features.
- Examples
- Generates a PrintName trait implementation that returns a struct’s name.
- What you can do after
- Apply quote! interpolation to generate code for a Rust derive macro.
Related concepts
- cargo addconfigured by · cargo add is a Cargo subcommand that adds a dependency declaration and its configuration to a Rust package’s manifest.
- TokenStreamproduces · TokenStream is a sequence of Rust source tokens used as input or output during procedural macro expansion and code generation.
- procedural macroused by · A procedural macro is a Rust macro implemented as a program that transforms an input token stream into generated code during compilation.
- call_siteuses · call_site is a Span-associated function that creates a span resolved at the location where a procedural macro is invoked.
- ToTokensuses · ToTokens is a quote trait whose implementations convert Rust syntax-related values into token streams.
- impl blockproduces · An impl block is a Rust construct that defines associated functions, methods, or trait implementations for a type.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

