Trait UnitEnum

Source
pub trait UnitEnum {
    type Unit: Debug + Clone + Copy + PartialEq + Eq + PartialOrd + Ord + Hash;

    // Required methods
    fn to_unit(&self) -> Self::Unit;
    fn unit_iter() -> Box<dyn Iterator<Item = Self::Unit>>;
}
Expand description

A utility trait for associating a data enum with a unit enum that has the same variants.

Required Associated Types§

Source

type Unit: Debug + Clone + Copy + PartialEq + Eq + PartialOrd + Ord + Hash

An enum with the same variants as the implementor but without any data.

Required Methods§

Source

fn to_unit(&self) -> Self::Unit

Turn this type into it’s unit enum.

Source

fn unit_iter() -> Box<dyn Iterator<Item = Self::Unit>>

Iterate over the unit variants.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl UnitEnum for ()

Needed as a base case for ignoring types.

Source§

type Unit = ()

Source§

fn to_unit(&self) -> <() as UnitEnum>::Unit

Source§

fn unit_iter() -> Box<dyn Iterator<Item = <() as UnitEnum>::Unit>>

Implementors§