Typed-quote: A fully typed quote!() alternative for both proc-macro and proc-macro2
โ Rust ๐ 2026-03-05 ๐ค surdeus ๐๏ธ 4Hi, I made a library called typed-quote. It acts like quote but doesnโt depend on proc-macro2.
proc-macro and proc-macro2 are optional features so you can choose any one, both or none of them.
This is useful when youโre just writing a small proc macro library.
For example:
quote!(hello #var).into_token_stream() // returns proc_macro::TokenStream
quote!(hello #var).into_token_stream2() // returns proc_macro2::TokenStream
typed-quote also provides trait WithSpan. Method with_default_span sets span for unspanned tokens, while method with_replaced_span replaces all spans.
See the docs here![]()
1 post - 1 participant
๐ท๏ธ Rust_feed