VariantCount

Trait VariantCount 

Source
pub trait VariantCount {
    type Counter;

    // Required method
    fn counter() -> Self::Counter;
}
Expand description

The core VariantCount trait which provides an accosiated counter() method to get the concrete counter type.

You should derive the VariantCount to auto impl this trait.

#[derive(VariantCount)]
pub enum Enum {
  Variant1,
  Variant2,
}

let mut counter = Enum::counter();
counter.record(&Enum::Variant1);

Required Associated Types§

Source

type Counter

A concrete counter type.

Required Methods§

Source

fn counter() -> Self::Counter

The accosiated function to get the concrete counter type.

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.

Implementors§