#enums #derive #bool #type #key #linearize #static-map

macro linearize-derive

Internal dependency of the linearize crate

1 unstable release

0.1.0 Nov 21, 2024

#41 in #bool

Download history 138/week @ 2024-11-18 12/week @ 2024-11-25 3/week @ 2024-12-02 12/week @ 2024-12-09 30/week @ 2024-12-16

68 downloads per month
Used in linearize

MIT/Apache

22KB
474 lines

linearize

crates.io docs.rs

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");
}

License

This project is licensed under either of

  • Apache License, Version 2.0
  • MIT License

at your option.

Dependencies

~230–680KB
~16K SLoC