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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/// Derive macro to implement [`Enum`] on enums.
///
/// ```
/// # use discriminant::Enum;
/// # #[allow(unused)]
/// #[derive(Enum)]
/// enum MyEnum {
/// Variant1,
/// Variant2(usize, &'static str),
/// Variant3 {
/// name: String,
/// age: i32,
/// }
/// }
/// ```
///
/// # Supported annotations
///
/// - `#[discriminant([path])]` ... sprcify path to the crate, defaults to `::discriminant`
/// - `#[discriminant_attr = "#[attr1] #[attr2] ..."]` ... specify annotations applied onto
/// [`Enum::Discriminant`] type or its variants, defined by the derive macro.
///
/// # [`Enum::Discriminant`] type
///
/// This macro also generates definition of `Discriminant` type,
/// which has the same layout with representation of the original enum (configurable using
/// `#[repr(...)]` attribute). The discriminant type is an enum which contains the same variants
/// with the original enum, but does not contain any fields (in other words, all of the variants of
/// the discriminant enum is tuple-like variant).
pub use Enum;
/// Represents an Enum definition, and supports method to get discriminant of a variant.
///
/// Implemented by `#[derive(Enum)]` derive macro.
pub unsafe
pub unsafe
// pub unsafe trait DiscriminantSet:
// IntoIterator<Item = Self::Discriminant>
// + Clone
// + Copy
// + core::fmt::Display
// + core::fmt::Debug
// + core::hash::Hash
// + PartialEq
// + Eq
// + PartialOrd
// + Sized
// + core::ops::Add
// + core::ops::Sub
// + core::ops::AddAssign
// + core::ops::SubAssign
// + core::iter::Sum
// {
// type Discriminant: Discriminant;
// }