| Crates.io | indexland |
| lib.rs | indexland |
| version | 0.2.1 |
| created_at | 2025-02-22 14:23:05.070227+00 |
| updated_at | 2025-03-07 03:31:21.349948+00 |
| description | Rust Collections with Newtype Indices |
| homepage | |
| repository | https://github.com/cmrschwarz/indexland |
| max_upload_size | |
| id | 1565417 |
| size | 125,512 |
Wrappers for common collection types based on newtype indices. Increased type safety and code readability without runtime overhead.
use indexland::{Idx, IndexVec};
#[derive(Idx)]
struct NodeId(u32);
struct Node<T> {
prev: NodeId,
next: NodeId,
data: T,
}
struct DoublyLinkedList<T> {
nodes: IndexVec<NodeId, Node<T>>,
}
use indexland::{enum_index_array, EnumIndexArray, Idx};
#[derive(Idx)]
enum PrimaryColor {
Red,
Green,
Blue,
}
const COLOR_MAPPING: EnumIndexArray<PrimaryColor, u32> = enum_index_array![
PrimaryColor::Red => 0xFF0000,
PrimaryColor::Green => 0x00FF00,
PrimaryColor::Blue => 0x0000FF,
];
let my_color = COLOR_MAPPING[PrimaryColor::Red];
IndexSlice<I, T>
wrapping &[T]IndexArray<I, T, LEN>
wrapping [T; LEN]IndexVec<I, T>
wrapping Vec<T>IndexVecDeque<I, T>
wrappingVecDeque<T>IndexSmallVec<I, T, CAP>
wrapping SmallVec<[T;CAP]> (Optional)IndexArrayVec<I, T, CAP>
wrapping ArrayVec<T, CAP> (Optional)IndexHashMap<I, K, V>
wrapping IndexMap<K, V> (Optional)IndexHashSet<I, T>
wrapping IndexSet<T> (Optional)NonMax<T> Integer Types for Niche Optimizations (Optional)serde support for all Collections (Optional)