//! A collection of utilities for working with enums.
use ;
pub use *;
/// A derivable trait for cyclic linear populated enums.
///
/// A cyclic enum is one whose variants can be iterated through bidirectionally
/// and wraps around at each boundary.
///
/// # Derivable
///
/// It is preferable to `derive` this trait instead of implementing it yourself.
/// You can use this trait with `#[derive]` for any enum so long as it has more
/// than one variant (i.e. its bit representation is greater than zero), none of
/// its variants have alternate discriminants (i.e. it starts at 0 and each
/// variant increments in value by 1) and all of its variants are unit variants.
///
/// When it is derived, you get a free implementation of [`SizedEnum`] and
/// [`TryFrom<usize>`][core::convert::TryFrom].
/// A list specifying categories of errors produced by [`Cycle::try_cycle_to`].
unsafe
unsafe
/// A derivable marker trait for populated enums that have default variants.
///
/// # Derivable
///
/// This can be used with `#[derive]` in one of two ways - with the `#[default]`
/// attribute for an explicit default, or alone for an implicit default. Under
/// the hood, this generates a free [`Default`] implementation for you. This
/// trait can be used with `#[derive]` for any enum whose default variant is
/// a unit variant.
///
/// It is a model solution for [RFC 3017 derive_enum_default][rfc-3017].
///
/// [rfc-3017]: https://rust-lang.github.io/rfcs/3107-derive-enum-default.html#derivedefault
///
/// ## Explicit defaults
///
/// Explicit defaults use the `#[default]` attribute on variants to denote the
/// default enum variant for the generated [`Default`] implementation.
///
/// ```
/// # use enumerare::DefaultEnum;
/// #[derive(DefaultEnum)]
/// enum Kind {
/// A,
/// #[default] B,
/// C,
/// }
/// ```
///
/// This would generate the following [`Default`] implementation for you:
///
/// ```
/// # enum Kind { B }
/// impl Default for Kind {
/// fn default() -> Kind { Kind::B }
/// }
/// ```
///
/// ## Implicit defaults
///
/// You can `derive` [`DefaultEnum`] without using the `#[default]` attribute to
/// select the first variant as an assumed default.
///
/// ```
/// # use enumerare::DefaultEnum;
/// #[derive(DefaultEnum)]
/// enum Kind {
/// A,
/// B,
/// C,
/// }
/// ```
///
/// This would generate the following [`Default`] implementation for you:
///
/// ```
/// # enum Kind { A }
/// impl Default for Kind {
/// fn default() -> Kind { Kind::A }
/// }
/// ```
/// A derivable trait for enums with public variant quantities, useful to
/// determine their bit size or ensure valid indexes.
///
/// # Derivable
///
/// You can use this trait with `#[derive]` for any enum, even empty ones.
///
/// # Examples
///
/// ```
/// # use enumerare::SizedEnum;
/// #[derive(SizedEnum)]
/// enum Kind {
/// A,
/// B,
/// C,
/// }
///
/// assert_eq!(Kind::VARIANTS, 3usize);
/// ```
///
/// ```
/// # use enumerare::SizedEnum;
/// #[derive(SizedEnum)]
/// enum Kind {}
///
/// assert_eq!(Kind::VARIANTS, 0usize);
/// ```