Trait MapValue

Source
pub trait MapValue: Sized {
    type Key;
    type Map;

    // Required methods
    fn to_key(&self) -> Self::Key;
    fn make_map() -> Self::Map;
}
Expand description

Implement this trait on your enum to bind a Map and Key type to it

Required Associated Types§

Source

type Key

Associated Key type (most likely an enum of unit variants)

Source

type Map

Map allowing 1-to-1 mapping between Keys and Value (Self)

Required Methods§

Source

fn to_key(&self) -> Self::Key

Match each enum variant to a Key

Source

fn make_map() -> Self::Map

Initialize an empty Map

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§