#enums #no-std

no-std linearize

Types that are enumerable and an array-backed map

5 releases

0.1.4 Feb 12, 2025
0.1.3 Jan 12, 2025
0.1.2 Jan 6, 2025
0.1.1 Nov 21, 2024
0.1.0 Nov 21, 2024

#215 in Data structures

Download history 17/week @ 2024-12-07 19/week @ 2024-12-14 19/week @ 2024-12-21 21/week @ 2024-12-28 137/week @ 2025-01-04 328/week @ 2025-01-11 758/week @ 2025-01-18 275/week @ 2025-01-25 143/week @ 2025-02-01 393/week @ 2025-02-08 873/week @ 2025-02-15 951/week @ 2025-02-22 988/week @ 2025-03-01 561/week @ 2025-03-08 387/week @ 2025-03-15 682/week @ 2025-03-22

2,760 downloads per month
Used in 3 crates (2 directly)

MIT/Apache

125KB
3K SLoC

linearize

crates.io docs.rs MSRV

This crate provides a trait that defines an enumeration of a type and an efficient no_std map that uses such types as keys.

Example

use linearize::{Linearize, static_map};

#[derive(Linearize)]
enum Keys {
    A,
    B(bool),
}

fn main() {
    let map = static_map! {
        Keys::A => "a",
        Keys::B(false) => "b",
        Keys::B(true) => "c",
    };
    assert_eq!(map[Keys::A], "a");
    assert_eq!(map[Keys::B(true)], "c");
}

MSRV

The MSRV is max(1.83, stable - 3).

License

This project is licensed under either of

  • Apache License, Version 2.0
  • MIT License

at your option.

Dependencies

~2–425KB