oxc-index-vec
Forked version of index_vec.
Features
This crate provides several optional features:
rayon- Enables parallel iteration support via Rayonserde- Enables serialization/deserialization support via Serdenonmax- Enablesdefine_nonmax_u32_index_type!macro for memory-efficient index types usingNonMaxU32
Usage
Add this to your Cargo.toml:
[]
= "3.1"
# Enable optional features as needed:
# oxc_index = { version = "3.1", features = ["serde", "nonmax"] }
Basic Index Type
use ;
define_index_type!
let mut vec: = new;
let idx = vec.push;
assert_eq!;
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 ;
define_nonmax_u32_index_type!
// Option<CompactIdx> is the same size as CompactIdx (4 bytes)
assert_eq!;
let mut vec: = new;
let idx = vec.push;
Serialization Support (requires serde feature)
All index types and IndexVec automatically support Serde serialization when the serde feature is enabled:
use ;
use ;
define_index_type!
Newly Added Features
Compared to the original index_vec:
rayonfeature - Parallel iteration supportserdefeature - Automatic serialization support using the crate's own serde dependencynonmaxfeature - Memory-efficient index types withdefine_nonmax_u32_index_type!macro- Const support - Many methods are now
const fnwhere possible - Proc macro compatibility - Macros work seamlessly with custom derive attributes like
#[ast],#[estree(skip)], etc.