#map-set #ordinal #integer #enums #traits #value #struct #set

macro ordinal-map-derive

Ordinal trait to map values to integers and efficient maps and sets for such types

8 releases

new 0.1.7 Jul 2, 2025
0.1.6 Jun 24, 2024

#29 in #ordinal

Download history 4/week @ 2025-03-13 2661/week @ 2025-03-20 3115/week @ 2025-03-27 4713/week @ 2025-04-03 8202/week @ 2025-04-10 6210/week @ 2025-04-17 3546/week @ 2025-04-24 6409/week @ 2025-05-01 7231/week @ 2025-05-08 4724/week @ 2025-05-15 6774/week @ 2025-05-22 10147/week @ 2025-05-29 7866/week @ 2025-06-05 7167/week @ 2025-06-12 8154/week @ 2025-06-19 6385/week @ 2025-06-26

31,794 downloads per month
Used in ordinal-map

MIT license

19KB
448 lines

Procedural macros for ordinal-map crate.

This crate does not have a public API, everything is re-exported from ordinal-map crate.


Ordinal types and collections

The library provides Ordinal trait to map types to usize values, proc-macro to derive Ordinal trait for structs and enums, and map and set implementations that use these types as keys efficiently.

Example

use ordinal_map::map::total::OrdinalTotalMap;
#[derive(ordinal_map::Ordinal)]
enum ErrorCategory {
    Network,
    Disk,
    Logic,
}

fn classify_error(error: &str) -> ErrorCategory {
    // ...
}

let mut error_counts: OrdinalTotalMap<ErrorCategory, u64> = OrdinalTotalMap::default();

for error in &errors {
    let category = classify_error(error);
    error_counts[category] += 1;
}

Dependencies

~180–600KB
~14K SLoC