Crate fast_map

source ·
Expand description

A small library and custom derive to create a map-like struct that uses match expressions to get and insert values.

If you know your keys at compile-time, this library will likely be faster than HashMap for supported map operations.

Provides map operations through strict::MapLike, which returns an error when attempting to use unknown keys, and easy::MapLike, which ignores missing keys and more closely matches the HashMap API.

§Usage

use fast_map::easy::MapLike;

fn main() {
    pub enum A { A, B, C, D };

    #[derive(Default, fast_map::FastMap)]
    #[fast_map(keys(A::A, A::B, A::C, A::D))]
    struct Foo(fast_map::Map4<A, String>);

    let mut foo = Foo::default();

    foo.insert(A::B, "B".into());

    assert_eq!(foo.get(A::B), Some(&"B".to_string()));

    assert_eq!(foo.get(A::C), None);

    foo.insert(A::C, "C".into());

    assert_eq!(foo.values().collect::<Vec<_>>().len(), 2);
}

Modules§

  • Provides a MapLike trait that ignores errors on missing keys (more like HashMap API)
  • Provides a MapLike trait that errors when trying to get or insert missing keys

Structs§

  • Container for a map with 1 field
  • Container for a map with 2 fields
  • Container for a map with 3 fields
  • Container for a map with 4 fields
  • Container for a map with 5 fields
  • Container for a map with 6 fields
  • Container for a map with 7 fields
  • Container for a map with 8 fields
  • Container for a map with 9 fields
  • Container for a map with 10 fields
  • Container for a map with 11 fields
  • Container for a map with 12 fields
  • Container for a map with 13 fields
  • Container for a map with 14 fields
  • Container for a map with 15 fields
  • Container for a map with 16 fields
  • Container for a map with 17 fields
  • Container for a map with 18 fields
  • Container for a map with 19 fields
  • Container for a map with 20 fields
  • Container for a map with 21 fields
  • Container for a map with 22 fields
  • Container for a map with 23 fields
  • Container for a map with 24 fields
  • Container for a map with 25 fields
  • Container for a map with 26 fields
  • Container for a map with 27 fields
  • Container for a map with 28 fields
  • Container for a map with 29 fields
  • Container for a map with 30 fields
  • Container for a map with 31 fields
  • Container for a map with 32 fields
  • Container for a map with 48 fields
  • Container for a map with 64 fields
  • Iterator over existing values

Enums§

  • Currently just KeyNotFound

Derive Macros§