fixed-map 0.1.3

A fixed map where storage layout is calculated by a procedural macro.
Documentation

fixed-map

Build Status

Note: this crate is still in heavy development. Please be careful!

This crate provides a map implementation that relies on fixed-size backing storage.

It accomplishes this by deriving an optimal storage strategy from the key to be used in the map using the Key derive:

#[derive(fixed_map::Key)]
pub enum Key {
    One,
    Two,
}

let mut map = fixed_map::Map::new();
assert_eq!(map.get(&Key::One), None);
map.insert(Key::One, 42);
assert_eq!(map.get(&Key::One), Some(&42));
assert_eq!(map.get(&Key::Two), None);

Missing APIs

The API of this project is incomplete since it is experimental. You can help by adding more!

Why does this crate exist?

There are many cases where you want associate a value with a small, fixed number of elements identified by an enum.

For example, let's say you have a game where each room has something in for directions:

#[derive(fixed_map::Key)]
pub enum Dir {
    North,
    East,
    South,
    West,
}

Now we can use this map to associate an item with each direction.

let mut map = fixed_map::Map::new();
map.insert(Dir::North, Item::Bow);

LICENSE

This project is distributed under the terms of both the MIT license and the Apache License (Version 2.0).

This project contains code derived from HashMap (Rust stdlib).