Closed arafatrahman862 closed 1 year ago
Hey! dtolnay, Thanks for your great work! ❤️
I think quote! and quote_spanned! macro should take &mut TokenStream instead of creating new one.
quote!
quote_spanned!
&mut TokenStream
Instead of this:
let import = items.iter().map(|item| quote_spanned!(item.span()=> use #item)); quote! { #(#import)* // ... }
I think it should look something like this:
// `to_tokens_fn` accept closure and return a struct that implement `ToTokens` let import = to_tokens_fn(|tokens| { for item in items { quote_spanned!(tokens, item.span()=> use #item); } }); impl ToTokens for <Struct> { fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) { quote!(tokens, { #import // ... }) } }
This approach should be more performance, Because it avoid cloning.
Sorry if this is duplicate.
I would prefer not to support this in this crate.
Hey! dtolnay, Thanks for your great work! ❤️
I think
quote!
andquote_spanned!
macro should take&mut TokenStream
instead of creating new one.Instead of this:
I think it should look something like this:
This approach should be more performance, Because it avoid cloning.
Sorry if this is duplicate.