dtolnay / paste

Macros for all your token pasting needs
Apache License 2.0
983 stars 53 forks source link

Possible to use bracket inside a paste expansion? #90

Closed bbaldino closed 1 year ago

bbaldino commented 1 year ago

I've got a use case where I need to do something like this:

[< <T>::read_ $type>](&buf)

And, from what I can tell, it seems like paste! might not like the nested brackets. The error I get when building is:

expected one of `(`, `::`, `<`, `>`, or `as`

Is this supported and I'm just missing something? Or is this not possible in paste!?

dtolnay commented 1 year ago

"\<T>::read_whatever" is not an identifier in Rust. Whatever you put inside of [<>] needs to result in a valid identifier, i.e. something that would be legal to use as the name of a variable.