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
87
88
/*!
* Macros that produce combinations of methods using the core module's [`is_variant`] and
* [`as_variant`] macros.
*/
// ------------------------------------------------------------------------------------------------
// Combinator Macros ❱ is_as_variant
// ------------------------------------------------------------------------------------------------
///
/// Generate both [`is_variant`] and [`as_variant`] for an enumeration variant.
///
/// ## Forms
///
/// ### `is_as_variant!(viz Enum, Variant => Type)`
///
/// This form generates both `is_variant` and `as_variant` for the applicable cases.
///
/// The following — commented line and following implementation — are therefore equivalent:
///
/// ```rust
/// use jemmy::*;
/// # pub struct Address(String);
/// pub enum TypedAddress {
/// Home(Address),
/// }
/// impl TypedAddress {
/// // is_as_variant!(pub Home => Address);
///
/// is_variant!(pub Home => Address);
/// as_variant!(pub Home => Address);
/// }
/// ```
///
/// ### `is_as_variant!(viz Enum, Variant => copy Type)`
///
/// This form generates both `is_variant` and `as_variant` for the applicable cases.
///
/// * This form requires `Type` implements `Copy`.
///
/// The following — commented line and following implementation — are therefore equivalent:
///
/// ```rust
/// use jemmy::*;
/// # pub struct Address(String);
/// pub enum TypedAddress {
/// XRef(u64),
/// }
/// impl TypedAddress {
/// // is_as_variant!(pub XRef => copy u64);
///
/// is_variant!(pub XRef => u64);
/// as_variant!(pub XRef => copy u64);
/// }
/// ```
///
// ------------------------------------------------------------------------------------------------
// Re-export macros
// ------------------------------------------------------------------------------------------------
pub use crateis_as_variant;