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
89
90
91
92
93
94
95
96
97
98
/// Create an [`ESet`](crate::ESet) with the `|` syntax.
///
/// This does not require the [`derive_eset`] macro being invoked.
///
/// Example
///
///```
/// # use eset::*;
/// # #[repr(u8)]
/// # #[derive(Debug)]
/// enum A {
/// Foo,
/// Bar,
/// }
/// # impl Into<u8> for A { fn into(self) -> u8 { self as u8 }}
/// #
/// # impl From<u8> for A {
/// # fn from(value: u8) -> Self {
/// # match value {
/// # 0 => Self::Foo,
/// # 1 => Self::Bar,
/// # _ => panic!()}}}
/// #
/// # impl ReprEnum for A {
/// # type Repr = u8;
/// # type FlagsRepr = u64;
/// # }
///
/// assert_eq!(eset!(A::Foo | A::Bar), ESet::new_flags([A::Foo, A::Bar]));
///```
/// An opt-in derive that adds [`Into<ESet<T>>`] for T and operator [`BitOr<T, Output=ESet<T>>`](std::ops::BitOr).
///
/// This supports T as the right hand side for [`ESet`](crate::ESet) operations like `|` or `&=`.
///
/// You can use methods like [`insert`](crate::ESet::insert) or [`with`](crate::ESet::with) instead of this macro.
///
/// # Examples
///
///```
/// # use eset::*;
/// # #[repr(u8)]
/// # #[derive(Debug)]
/// enum A {
/// Foo,
/// Bar,
/// }
/// # impl Into<u8> for A { fn into(self) -> u8 { self as u8 }}
/// #
/// # impl From<u8> for A {
/// # fn from(value: u8) -> Self {
/// # match value {
/// # 0 => Self::Foo,
/// # 1 => Self::Bar,
/// # _ => panic!()}}}
/// #
/// # impl ReprEnum for A {
/// # type Repr = u8;
/// # type FlagsRepr = u64;
/// # }
///
/// derive_eset!(A);
/// assert_eq!(A::Foo | A::Bar, ESet::new_flags([A::Foo, A::Bar]));
///```