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

macro linearize-derive

Internal dependency of the linearize crate

1 unstable release

new 0.1.0 Nov 21, 2024

#982 in Procedural macros


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

~215–650KB
~15K SLoC