| Crates.io | flatmap |
| lib.rs | flatmap |
| version | 0.1.1 |
| created_at | 2026-01-04 11:54:37.15371+00 |
| updated_at | 2026-01-04 12:07:01.595596+00 |
| description | Fast and Efficient Linear Map and Set for small collections |
| homepage | |
| repository | https://github.com/ash-hashtag/flatmap |
| max_upload_size | |
| id | 2021805 |
| size | 22,339 |
Fast and efficient linear map and set for small collections.
FlatMap<K, V> - Dynamic linear map with O(n) operationsFlatSet<K> - Dynamic linear set with O(n) operationsConstantFlatMap<K, V, N> - Fixed-size map with compile-time capacityConstantFlatSet<K, N> - Fixed-size set with compile-time capacityuse flatmap::{FlatMap, FlatSet, ConstantFlatMap, ConstantFlatSet};
// Dynamic map
let mut map = FlatMap::new();
map.insert("key", 42);
assert_eq!(map.get(&"key"), Some(&42));
// Dynamic set
let mut set = FlatSet::new();
set.insert("item");
assert!(set.has(&"item"));
// Fixed-size map
let const_map = ConstantFlatMap::from([("a", 1), ("b", 2)]);
assert_eq!(const_map.get(&"a"), Some(&1));
// Fixed-size set
let const_set = unsafe { ConstantFlatSet::from_entries_unchecked([1, 2, 3]) };
assert!(const_set.has(&2));
Optimized for small collections where linear search is faster than hash-based lookups due to better cache locality and lower overhead.
MIT