6 releases

Uses old Rust 2015

0.2.2 Oct 4, 2019
0.2.1 Sep 10, 2019
0.2.0 Jul 29, 2019
0.1.3 Jul 5, 2019
0.1.2 Jan 18, 2019

#139 in #derive-debug

Download history 373/week @ 2023-11-30 527/week @ 2023-12-07 537/week @ 2023-12-14 203/week @ 2023-12-21 222/week @ 2023-12-28 575/week @ 2024-01-04 501/week @ 2024-01-11 350/week @ 2024-01-18 445/week @ 2024-01-25 593/week @ 2024-02-01 643/week @ 2024-02-08 714/week @ 2024-02-15 844/week @ 2024-02-22 678/week @ 2024-02-29 628/week @ 2024-03-07 400/week @ 2024-03-14

2,657 downloads per month

MIT/Apache

25KB
488 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);
    }
}

Dependencies

~185KB