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

#128 in #derive-debug

Download history 396/week @ 2024-07-28 377/week @ 2024-08-04 448/week @ 2024-08-11 368/week @ 2024-08-18 403/week @ 2024-08-25 315/week @ 2024-09-01 336/week @ 2024-09-08 330/week @ 2024-09-15 319/week @ 2024-09-22 265/week @ 2024-09-29 310/week @ 2024-10-06 402/week @ 2024-10-13 440/week @ 2024-10-20 453/week @ 2024-10-27 307/week @ 2024-11-03 229/week @ 2024-11-10

1,471 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

~170KB