New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Option<T> repetitions do not work #213
Comments
This may not address your actual use, but you can just do fn test(option: Option<TokenStream>) -> TokenStream {
quote! {
#option
}
} This precludes other fancy stuff you might want to do inside the Agreed that the docs appear to be inaccurate based on the current implementation: Line 54 in ae25ab6
|
This might count as a breaking change, but what if there was a |
Ran into this problem today with a vector of options. Confused the heck out of me. Ended up doing this. Not particularly pretty but it works. let vec_of_options: Vec<Option<String>> = vec![/* stuff */];
let vec_of_options_tokenised: Vec<TokenStream> = vec_of_options
.into_iter()
.map(|opt| match opt {
Some(text) => quote! { Some(#text) },
None => quote! { None },
})
.collect();
// in quote macro, use `vec_of_options_tokenised` instead of `vec_of_options` |
Hello,
While trying to do the following thing,
it gives me the following error:
The type
Option<T>
does not work in repetitions (#()*
), while stated otherwise in the README.md here, sinceOption<T>
implementsIntoIterator
.I also found something stating the inverse here:
I ended up fixing my code by doing this:
fn test(option: Option<TokenStream>) -> TokenStream { + let option = option.iter(); quote! { #(#option)* } }
Also I have a few questions:
$()?
, since#()*
does not work out of the box ?IntoIterator
mechanism be introduced in order to achieve this without requiring.iter()
everywhere ?Thanks :)
The text was updated successfully, but these errors were encountered: