Typed-quote: A fully typed quote!() alternative for both proc-macro and proc-macro2

โš“ Rust    ๐Ÿ“… 2026-03-05    ๐Ÿ‘ค surdeus    ๐Ÿ‘๏ธ 4      

surdeus

Hi, 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:purple_heart:

1 post - 1 participant

Read full topic

๐Ÿท๏ธ Rust_feed