Crates.io | linearize |
lib.rs | linearize |
version | 0.1.4 |
source | src |
created_at | 2024-11-21 11:13:09.655508+00 |
updated_at | 2025-02-12 12:36:30.262405+00 |
description | Types that are enumerable and an array-backed map |
homepage | |
repository | https://github.com/mahkoh/linearize |
max_upload_size | |
id | 1456039 |
size | 126,768 |
This crate provides a trait that defines an enumeration of a type and an efficient no_std map that uses such types as keys.
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");
}
The MSRV is max(1.83, stable - 3)
.
This project is licensed under either of
at your option.