fixed-hashmap 0.1.0

A fixed-capacity, allocation-free hashmap for fixed-size byte keys and values
Documentation
use core::mem::MaybeUninit;
use fixed_hashmap::{EntryStorage, FastHasher, FixedMap, KeyHasher};

struct RecordsHasher;

impl KeyHasher<4> for RecordsHasher {
    fn hash(&self, key: &[u8; 4]) -> u64 {
        let mut namespaced_key = [0; 12];
        namespaced_key[..8].copy_from_slice(b"records:");
        namespaced_key[8..].copy_from_slice(key);
        FastHasher.hash(&namespaced_key)
    }
}

fn main() {
    const CAPACITY: usize = 4;
    let mut entries: [EntryStorage<4, 8>; CAPACITY * 2] =
        core::array::from_fn(|_| MaybeUninit::uninit());
    let mut tags = [0; CAPACITY * 2];
    let mut map = FixedMap::<CAPACITY, 4, 8, RecordsHasher>::with_hasher(
        &mut entries,
        &mut tags,
        RecordsHasher,
    )
    .expect("backing storage has twice the entry capacity");

    map.insert(*b"key1", *b"value001")
        .expect("the map has free capacity");
    assert_eq!(map.get(b"key1"), Some(b"value001"));
}