Crate enum_collections

source ·
Expand description

§Enum collections

See EnumMap for usage details.

A map of enum variants to values. EnumMap is a fixed-size map, where each variant of the enum is mapped to a value. This implementation of EnumMap uses safe Rust only and is a a zero-cost abstraction over an array (const-sized), where the index of the array corresponds to the position of the variant in the enum.

Because it is a thin wrapper over an array, it is stack-allocated by default. Simply std::boxed::Boxing it will move it to the heap, at the caller’s discretion.

  • Indexed by enum variants.
  • IndexMut by enum variants.
  • Debug if the enum is Debug.
  • PartialEq if the value is PartialEq. Same for Eq.

Debug and Eq are optional features. They are enabled by default.

Re-exports§

  • pub use crate::enumerated::Enumerated;

Macros§

  • Creates an EnumMap with user-provided values.
  • Initializes an EnumMap with default values for all variants not explicitly specified.
  • Initializes an EnumMap with Option::None for all variants not explicitly specified.

Structs§

  • A map of enum variants to values. EnumMap is a fixed-size map, where each variant of the enum is mapped to a value. EnumMap is a a zero-cost abstraction over an array, where the index of the array corresponds to the position of the variant in the enum.

Derive Macros§

  • Creates enum_map::Enumerated implementation for the underlying Enum. Also derives Copy and Clone.