Say I have some external library code (that is also generated from a procedural macro itself):
struct Type1;
struct Type2<'a> (&'a str);
struct Type3<'a> (&'a str);
// Expanded definition from a proc macro
enum Enum<'a> {
A,
B,
C(Type1),
D,
E(Type2<'a>),
F,
G(Type3<'a>),
H(Type1),
I
}
I want to use procedural macros to generate the following:
// These types are hand-written
struct Type1;
struct Type2 (String);
struct Type3 (String);
// Generated from procedural macros and pattern-matching?
enum Enum {
A,
B,
C(Type1),
D,
E(Type2),
F,
G(Type3),
H(Type1),
I
}
Is this possible?
Here, the comparison between '&str
and String
is a toy example but in reality could be an arbitrarily complex type that needs manual conversion.