I have a few different use cases for joining paths and identifiers in macros:
- Accept a
path
to amod
and repeatedident
s and join them to make types without repeating themod
. - Accept a
path
to anenum
type and repeatedidents
and join them to either construct instances of theenum
, or to use in match arms, without having to repeat the name of theenum
. - etc
I've managed to make a few of these use cases work, but an intuitive, multi-purpose "just join these tokens with ::
" mechanism is eluding me.
Intuitively, I'd be able to say $my_mod:path, $my_type:ident
and then construct $my_mod::$my_type(my, args)
, but that doesn't work. If I do $my_enum_type:ty, $my_enum_case:ident
, I can construct enum
s with <$my_enum_type>::$my_enum_case(my, args)
, but I can't write a match arm in the same way.
Is there some syntax here I'm missing? So far, I don't actually understand the use case for a path
designator at all, given that I can't seem to combine paths in any interesting way.