You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Although __proc_macro__as_repeat is a very unique name, in theory it can collide if the struct being interpolated in a repetition also implements some function with that name.
Trying to solve this with the fully qualified syntax Repeat::__proc_macro__as_repeat(something), would raise a new issue.
While iterators have to be consumed to be used (transfer ownership), slices and ToTokens shouldn't (borrow reference). On the other hand, the macro must generate code that simultaneously can work in both situations. This means Repeat::__proc_macro__as_repeat(&something) couldn't be generated, otherwise iterators wouldn't work. On the other hand, using Repeat::__proc_macro__as_repeat(something), the compiler doesn't infer the reference for some reason (while something.__proc_macro__as_repeat() does), so slices and ToTokens wouldn't work directly.
The user would need to borrow the variables before passing them into the macro, which could get very annoying:
let a = vec!["a","b","c"];let b = [5,6,7];let c = 5;let d = "a";let e = X;let a = &a;let b = &b;let c = &c;let d = &d;let e = &e;let q = quote!{ #(#a #b #c #d #e)*};
The text was updated successfully, but these errors were encountered:
Although
__proc_macro__as_repeat
is a very unique name, in theory it can collide if the struct being interpolated in a repetition also implements some function with that name.Trying to solve this with the fully qualified syntax
Repeat::__proc_macro__as_repeat(something)
, would raise a new issue.While iterators have to be consumed to be used (transfer ownership), slices and
ToTokens
shouldn't (borrow reference). On the other hand, the macro must generate code that simultaneously can work in both situations. This meansRepeat::__proc_macro__as_repeat(&something)
couldn't be generated, otherwise iterators wouldn't work. On the other hand, usingRepeat::__proc_macro__as_repeat(something)
, the compiler doesn't infer the reference for some reason (whilesomething.__proc_macro__as_repeat()
does), so slices and ToTokens wouldn't work directly.The user would need to borrow the variables before passing them into the macro, which could get very annoying:
The text was updated successfully, but these errors were encountered: