#proc-macro #quote

quote2

An alternative lightweight version of quote

2 unstable releases

0.7.0 Jul 4, 2023
0.5.0 Jul 3, 2023
0.3.0 Jul 3, 2023
0.2.0 Jul 1, 2023
0.1.0 Jul 1, 2023

#382 in Procedural macros

Download history 25/week @ 2023-10-19 25/week @ 2023-10-26 26/week @ 2023-11-02 23/week @ 2023-11-09 26/week @ 2023-11-16 30/week @ 2023-11-23 28/week @ 2023-11-30 29/week @ 2023-12-07 27/week @ 2023-12-14 29/week @ 2023-12-21 16/week @ 2023-12-28 24/week @ 2024-01-04 27/week @ 2024-01-11 21/week @ 2024-01-18 22/week @ 2024-01-25 23/week @ 2024-02-01

97 downloads per month
Used in 4 crates (2 directly)

MIT license

7KB
144 lines

An alternative lightweight version of quote.

Unlike quote, this library avoids cloning whenever possible.

Example

Add it as a dependency to your Rust project by adding the following line to your Cargo.toml file:

[dependencies]
quote2 = "0.7"
use quote2::{proc_macro2::TokenStream, quote, Quote};

let body = quote(|tokens| {
    for i in 0..3 {
        quote!(tokens, {
            println!("{}", #i);
        });
    }
});

let mut tokens = TokenStream::new();
quote!(tokens, {
    fn name() {
        #body
    }
});

Generated code:

fn name() {
    println!("{}", 0i32);
    println!("{}", 1i32);
    println!("{}", 2i32);
}

Dependencies

~84KB