Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upSupport duplicate interpolations inside a repetition #8
Comments
dtolnay
added
the
enhancement
label
Oct 9, 2016
This comment has been minimized.
This comment has been minimized.
|
I don't think this is possible with Rewriting |
This comment has been minimized.
This comment has been minimized.
purpleposeidon
commented
Feb 25, 2017
•
|
This is the work-around I have been using for this issue:
|
This comment has been minimized.
This comment has been minimized.
purpleposeidon
commented
Feb 25, 2017
|
Nope, that doesn't actually compile! #[macro_use]
extern crate quote;
fn main() {
let foo: Vec<&str> = Vec::new();
let foo2 = &foo;
quote! {
#(#foo #foo2)*
};
}
--pretty expanded makes it obvious why: fn main() {
let foo: Vec<&str> = Vec::new();
let foo2 = &foo;
{
let mut _s = $crate::Tokens::new();
for (foo, foo2) in foo.into_iter().zip(foo2) {
$crate::ToTokens::to_tokens(&foo, &mut _s);
$crate::ToTokens::to_tokens(&foo2, &mut _s);
};
_s
};
} |
This comment has been minimized.
This comment has been minimized.
let ref foo: Vec<&str> = Vec::new();
let foo2 = foo;
quote! {
#(#foo #foo2)*
}; |
This comment has been minimized.
This comment has been minimized.
JeanMertz
commented
Sep 11, 2018
•
|
For reference, I ran into this today. I am porting a fairly complex Since funclike proc-macro's are (almost?) a thing now, perhaps it's time to start thinking about that rewrite for
Not sure why I didn't realise the post above was the current workaround, but that works as expected |
dtolnay commentedOct 9, 2016
quote! { #a #a }works butquote! { #(#a #a)* }does not.