quote2 0.3.0

An alternative lightweight version of quote
Documentation
quote2-0.3.0 has been yanked.

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.3"
use quote2::{proc_macro2::TokenStream, quote, Quote};

let mut tokens = TokenStream::new();
let body = quote(|tokens| {
    for i in 0..3 {
        quote!(tokens, {
            println!("{}", #i);
        });
    }
});
quote!(tokens, {
    fn name() {
        #body
    }
});

Generated code:

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