Crates.io | quote2 |
lib.rs | quote2 |
version | 0.7.0 |
source | src |
created_at | 2023-07-01 17:50:40.223349 |
updated_at | 2023-07-04 03:59:35.33293 |
description | An alternative lightweight version of quote |
homepage | |
repository | https://github.com/nurmohammed840/quote2 |
max_upload_size | |
id | 905613 |
size | 6,772 |
An alternative lightweight version of quote.
Unlike quote
, this library avoids cloning whenever possible.
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);
}