liveBook · Manning

Quote

quote is a Rust crate and macro for constructing Rust token streams from quasi-quoted syntax.

How 2 Manning books explain it

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.

Read how Write Powerful Rust Macros explains quote →

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.

Read how Idiomatic Rust explains quote →

Related concepts

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.