#data-structure #no-std #enum

no-std enum-map-derive

Macros 1.1 implementation of #[derive(Enum)]

25 releases

Uses old Rust 2015

0.6.0 May 16, 2021
0.5.0 Mar 28, 2021
0.4.6 Oct 27, 2020
0.4.3 Sep 10, 2019
0.2.2 May 18, 2017

#516 in Data structures

Download history 9891/week @ 2021-06-07 10618/week @ 2021-06-14 12066/week @ 2021-06-21 11945/week @ 2021-06-28 10777/week @ 2021-07-05 11136/week @ 2021-07-12 10507/week @ 2021-07-19 12312/week @ 2021-07-26 10555/week @ 2021-08-02 9818/week @ 2021-08-09 10909/week @ 2021-08-16 10955/week @ 2021-08-23 11410/week @ 2021-08-30 10148/week @ 2021-09-06 11947/week @ 2021-09-13 13012/week @ 2021-09-20

37,365 downloads per month
Used in 127 crates (3 directly)

MIT/Apache

4KB
72 lines

enum-map

A library providing enum map providing type safe enum array. It is implemented using regular Rust arrays, so using them is as fast as using regular Rust arrays.

This library doesn't provide Minimum Supported Rust Version (MSRV). If you find having MSRV valuable, please use enum-map 0.6 instead.

Examples

#[macro_use]
extern crate enum_map;

use enum_map::EnumMap;

#[derive(Debug, Enum)]
enum Example {
    A,
    B,
    C,
}

fn main() {
    let mut map = enum_map! {
        Example::A => 1,
        Example::B => 2,
        Example::C => 3,
    };
    map[Example::C] = 4;

    assert_eq!(map[Example::A], 1);

    for (key, &value) in &map {
        println!("{:?} has {} as value.", key, value);
    }
}

lib.rs:

Procedural macro implementing #[derive(Enum)]

This is supposed to used with enum-map crate, which provides the actual usage documentation.

Dependencies

~310–730KB
~18K SLoC