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
//! Silly enum helpers.
pub use Name;
/// Generates `is_*` predicate methods for each enum variant.
///
/// The name of a predicate method is `is_` followed by the variant's
/// identifier in snake_case. `Foo` becomes `is_foo` and `HelloWorld`
/// becomes `is_hello_world`.
///
/// ```rust
/// use enum_fun::Predicates;
///
/// #[derive(Predicates)]
/// enum Words {
/// Foo,
/// Bar,
/// # SnakeCaseTest,
/// }
///
/// use Words::*;
///
/// assert!(Foo.is_foo());
/// assert!(!Foo.is_bar());
///
/// assert!(Bar.is_bar());
/// assert!(!Bar.is_foo());
/// #
/// # assert!(SnakeCaseTest.is_snake_case_test());
/// ```
pub use Predicates;
/// Generates inherent constants and an iterator method
/// to enable iterating and indexing the enum variants.
///
/// ```rust
/// use enum_fun::Variants;
///
/// #[derive(Debug, PartialEq, Variants)]
/// enum Words {
/// Foo,
/// Bar,
/// Baz,
/// }
///
/// use Words::*;
///
/// assert_eq!(Words::VARIANT_COUNT, 3);
/// assert_eq!(Words::VARIANTS, [Foo, Bar, Baz]);
/// assert_eq!(Words::variants().collect::<Vec<_>>(), vec![Foo, Bar, Baz]);
/// ```
///
/// The return type of the `variants()` method is an `impl ExactSizeIterator<Item = Self>`.
///
/// Only enums without fields are supported.
pub use Variants;