indexland

Crates.ioindexland
lib.rsindexland
version
sourcesrc
created_at2025-02-22 14:23:05.070227+00
updated_at2025-03-07 03:31:21.349948+00
descriptionRust Collections with Newtype Indices
homepage
repositoryhttps://github.com/cmrschwarz/indexland
max_upload_size
id1565417
Cargo.toml error:TOML parse error at line 19, column 1 | 19 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
Christian Schwarz (cmrschwarz)

documentation

README

Indexland

githubgithub-buildcrates-iomsrvdocs-rs

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

License

MIT

Commit count: 0

cargo fmt