oxc_index

Forked version of index_vec

Latest version: 4.1.0 registry icon
Maintenance score
100
Safety score
100
Popularity score
72
Check your open source dependency risks. Get immediate insight about security, stability and licensing risks.
Security
  Vulnerabilities
Version Suggest Low Medium High Critical
4.1.0 0 0 0 0 0
4.0.0 0 0 0 0 0
3.1.0 0 0 0 0 0
3.0.0 0 0 0 0 0
2.0.1 0 0 0 0 0
2.0.0 0 0 0 0 0
1.0.1 0 0 0 0 0
1.0.0 0 0 0 0 0
0.37.0 0 0 0 0 0
0.36.0 0 0 0 0 0
0.35.0 0 0 0 0 0
0.34.0 0 0 0 0 0
0.33.0 0 0 0 0 0
0.32.0 0 0 0 0 0
0.31.0 0 0 0 0 0
0.30.5 0 0 0 0 0
0.30.4 0 0 0 0 0
0.30.3 0 0 0 0 0
0.30.2 0 0 0 0 0
0.30.1 0 0 0 0 0
0.30.0 0 0 0 0 0
0.29.0 0 0 0 0 0
0.28.0 0 0 0 0 0
0.27.0 0 0 0 0 0
0.26.0 0 0 0 0 0
0.25.0 0 0 0 0 0
0.24.3 0 0 0 0 0
0.24.2 0 0 0 0 0
0.24.1 0 0 0 0 0
0.24.0 0 0 0 0 0
0.23.1 0 0 0 0 0
0.23.0 0 0 0 0 0
0.22.1 0 0 0 0 0
0.22.0 0 0 0 0 0
0.21.0 0 0 0 0 0
0.20.0 0 0 0 0 0
0.19.0 0 0 0 0 0
0.18.0 0 0 0 0 0
0.17.2 0 0 0 0 0
0.17.1 0 0 0 0 0
0.17.0 0 0 0 0 0
0.16.3 0 0 0 0 0
0.16.2 0 0 0 0 0
0.16.1 0 0 0 0 0
0.16.0 0 0 0 0 0
0.15.0 0 0 0 0 0
0.14.0 0 0 0 0 0
0.13.5 0 0 0 0 0
0.13.4 0 0 0 0 0
0.13.3 0 0 0 0 0
0.13.2 0 0 0 0 0
0.13.1 0 0 0 0 0
0.13.0 0 0 0 0 0
0.12.5 0 0 0 0 0
0.12.4 0 0 0 0 0
0.12.3 0 0 0 0 0
0.12.2 0 0 0 0 0
0.12.1 0 0 0 0 0
0.11.1 0 0 0 0 0
0.11.0 0 0 0 0 0
0.10.0 0 0 0 0 0
0.9.0 0 0 0 0 0
0.8.0 0 0 0 0 0
0.7.0 0 0 0 0 0
0.6.0 0 0 0 0 0
0.5.0 0 0 0 0 0
0.4.0 0 0 0 0 0
0.3.0 0 0 0 0 0
0.2.0 0 0 0 0 0
0.1.3 0 0 0 0 0
0.1.2 0 0 0 0 0
0.1.1 0 0 0 0 0
0.1.0 0 0 0 0 0
0.0.7 0 0 0 0 0

Stability
Latest release:

4.1.0 - This version is safe to use because it has no known security vulnerabilities at this time. Find out if your coding project uses this component and get notified of any reported security vulnerabilities with Meterian-X Open Source Security Platform

Licensing

Maintain your licence declarations and avoid unwanted licences to protect your IP the way you intended.

MIT   -   MIT License

Not a wildcard

Not proprietary

OSI Compliant



Crates.io Docs.rs MIT licensed Build Status Sponsors Discord chat

oxc-index-vec

Forked version of index_vec.

Features

This crate provides several optional features:

  • rayon - Enables parallel iteration support via Rayon
  • serde - Enables serialization/deserialization support via Serde
  • nonmax - Enables define_nonmax_u32_index_type! macro for memory-efficient index types using NonMaxU32

Usage

Add this to your Cargo.toml:

[dependencies]
oxc_index = "3.1"

# Enable optional features as needed:
# oxc_index = { version = "3.1", features = ["serde", "nonmax"] }

Basic Index Type

use oxc_index::{IndexVec, define_index_type};

define_index_type! {
    pub struct MyIdx = u32;
}

let mut vec: IndexVec<MyIdx, &str> = IndexVec::new();
let idx = vec.push("hello");
assert_eq!(vec[idx], "hello");

Memory-Efficient Index Type (requires nonmax feature)

The define_nonmax_u32_index_type! macro creates index types backed by NonMaxU32, which uses the niche optimization to store Option<MyIdx> in the same space as MyIdx:

use oxc_index::{IndexVec, define_nonmax_u32_index_type};

define_nonmax_u32_index_type! {
    pub struct CompactIdx;
}

// Option<CompactIdx> is the same size as CompactIdx (4 bytes)
assert_eq!(
    std::mem::size_of::<CompactIdx>(),
    std::mem::size_of::<Option<CompactIdx>>()
);

let mut vec: IndexVec<CompactIdx, String> = IndexVec::new();
let idx = vec.push("world".to_string());

Serialization Support (requires serde feature)

All index types and IndexVec automatically support Serde serialization when the serde feature is enabled:

use oxc_index::{IndexVec, define_index_type};
use serde::{Serialize, Deserialize};

define_index_type! {
    pub struct MyIdx = u32;
}

#[derive(Serialize, Deserialize)]
struct MyData {
    items: IndexVec<MyIdx, String>,
}

Newly Added Features

Compared to the original index_vec:

  • rayon feature - Parallel iteration support
  • serde feature - Automatic serialization support using the crate's own serde dependency
  • nonmax feature - Memory-efficient index types with define_nonmax_u32_index_type! macro
  • Const support - Many methods are now const fn where possible
  • Proc macro compatibility - Macros work seamlessly with custom derive attributes like #[ast], #[estree(skip)], etc.

My sponsors