1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#[macro_export]
macro_rules! VARIANT_COUNT {
derive() (
// <enum_parse: start> NOTE: generated by `generate.rs`
$(#[$($enum_attr:tt)*])*
$enum_vis:vis enum $enum_ident:ident
// a best-effort parsing of generics
//
// what's missing:
//
// - more than 1 lifetime bound (e.g. 'a: 'b + 'c)
// - more than 1 trait bound (e.g. T: A + B + C)
// - support for "use" TypeParam in trait bounds
// - `const` type parameters are totally unsupported
// - `for<..>` lifetimes in `where` clause
$(<
$(
$(#[$($type_param_attr:tt)*])*
// lifetime parameter
$($type_param_lifetime:lifetime $(: $type_param_lifetime_super:lifetime)?)?
// type parameter
$($type_param_type:ident
$(:
$($type_param_lifetime_bound:lifetime)?
$($type_param_type_bound:path)?
)? $(= $type_param_default:ty)?
)?
),*
$(,)?
>)?
$(where $(
$($where_lifetime:lifetime: $where_lifetime_bounds:lifetime)?
$($where_type_param_ty:ty: $where_type_param_bounds:path)?
),*)?
{
$(
$(#[$($enum_variant_attr:tt)*])*
$enum_variant:ident
// enum with named fields
$({
$(
$(#[$($enum_variant_named_field_attr:tt)*])*
$enum_variant_named_field_ident:ident: $enum_variant_named_field_ty:ty
),* $(,)?
})?
// enum with unnamed fields
$((
$(
$(#[$($enum_variant_unnamed_field_attr:tt)*])*
$enum_variant_unnamed_field_ty:ty
),* $(,)?
))?
// discriminant
$(= $enum_variant_discriminant:expr)?
),* $(,)?
}
// <enum_parse: end>
) => {
};
}