amap

Crates.ioamap
lib.rsamap
version0.1.2
sourcesrc
created_at2023-08-15 01:45:51.886897
updated_at2023-08-20 05:15:16.908917
descriptiondefine `[Option; N]` easily
homepage
repositoryhttps://github.com/bend-n/amap.git
max_upload_size
id944672
size7,266
bendn (bend-n)

documentation

README

amap

Simple array initialization macro.

Ever wanted to create a const HashMap<usize, T>, and started thinking, wouldn't it be nice if this was a array?

No?

Well now you can! Its as simple as

amap! {
  4 => 56,
  2 => 32,
} // creates a [Option<i32>; 5] for all your indexing needs

Think it would be too much boilerplate to have multiple keys for one value?

Patterns got you covered!

amap! {
  0..=4 => 2,
  5 | 6 => 3,
}

Want to put it in a constant? No problem!

It's just a array!

const ID_MAP: [Option<i32>; 6] = amap! {
  5 => 6,
  2 => 1,
}
Commit count: 3

cargo fmt