Expand description
§Indexland
Wrappers for common collection types based on newtype indices. Increased type safety and code readability without runtime overhead.
§Newtype Indices
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>>,
}§Enums as Indices
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];§Support for most common Array Based Collections
IndexSlice<I, T>wrapping&[T]IndexArray<I, T, LEN>wrapping[T; LEN]IndexVec<I, T>wrappingVec<T>IndexVecDeque<I, T>wrappingVecDeque<T>IndexSmallVec<I, T, CAP>wrappingSmallVec<[T;CAP]>(Optional)IndexArrayVec<I, T, CAP>wrappingArrayVec<T, CAP>(Optional)IndexHashMap<I, K, V>wrappingIndexMap<K, V>(Optional)IndexHashSet<I, T>wrappingIndexSet<T>(Optional)NonMax<T>Integer Types for Niche Optimizations (Optional)serdesupport for all Collections (Optional)
§License
Modules§
- idx
- idx_
enumerate - idx_
range - This is a wrapper around
core::ops::Range. - index_
array - index_
array_ vec arrayvec - index_
hash_ map indexmap - index_
hash_ set indexmap - index_
slice - index_
slice_ index - index_
small_ vec smallvec - index_
vec alloc - index_
vec_ deque alloc - nonmax
nonmax - Integers with a niche value based on
NonZero, allowing for better enum layout optimizations.
Macros§
- enum_
index_ array - Create a
EnumIndexArraycontaining the arguments. - idx_
newtype - Declarative alternative to
#[derive(IdxNewtype)]. - index_
array - Create a
IndexArraycontaining the arguments. - index_
array_ vec - Create an
IndexArrayVeccontaining the arguments. - index_
hash_ map - Create an
IndexHashMapcontaining the arguments. - index_
hash_ set - Create an
IndexHashSetcontaining the arguments. - index_
small_ vec - Create an
IndexSmallVeccontaining the arguments. - index_
vec - Create an
IndexVeccontaining the arguments. - index_
vec_ deque - Create an
IndexVecDequecontaining the arguments.
Structs§
- IdxRange
- IdxRange
Inclusive - Index
Array - Index
Array Vec arrayvec - Index
Hash Map indexmap - Index
Hash Set indexmap - Index
Slice - Index
Small Vec smallvec - Index
Vec alloc - Index
VecDeque alloc - NonMax
nonmax - Generic
NonMax
Traits§
Type Aliases§
- Enum
Index Array - Helper to construct
IndexArray<E, T, { <E as IdxEnum>::COUNT } >.
Derive Macros§
- Idx
derive - For structs this is equivalent to
#[derive(IdxNewtype)], for enums to#[derive(IdxEnum)]. - IdxEnum
derive - Implements the following traits:
- IdxNewtype
derive - Implements the following traits: