#deletion #array #growable #process #heap-allocated #contiguous #content

no-std opt_vec

A wrapper around Vec<Option<T> that makes deletion fast

3 releases

0.1.2 Aug 9, 2023
0.1.1 Aug 8, 2023
0.1.0 Aug 8, 2023

#1411 in Data structures


Used in wasper

MIT license

8KB
116 lines

opt_vec

Crate

A contiguous growable array type with heap-allocated contents with fast deletion process.

This is a wrapper for Vec<Option<T>>


lib.rs:

A contiguous growable array type with heap-allocated contents with fast deletion process.

This is a wrapper for Vec<Option<T>>

Use an OptVec when:

  • You want fast random access and deletion, but don't want to use expensive structures like HashMap.
  • You want to guarantee that the same index keeps the same value even if another element is removed.

Getting Started

Cargo.toml

[dependencies]
opt_vec = "*"

and then

use opt_vec::OptVec;

let mut v = OptVec::new();
v.push(1);

Support no_std

Cargo.toml

[dependencies.opt_vec]
version = "*"
default-features = false
features = ["alloc"]

No runtime deps

Features