#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 86/week @ 2024-11-15 60/week @ 2024-11-22 7/week @ 2024-11-29 11/week @ 2024-12-06 19/week @ 2024-12-13 17/week @ 2024-12-20 26/week @ 2024-12-27 2/week @ 2025-01-03 120/week @ 2025-01-10 762/week @ 2025-01-17 304/week @ 2025-01-24 132/week @ 2025-01-31 191/week @ 2025-02-07

1,415 downloads per month
Used in 4 crates (via 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

~205–640KB
~15K SLoC