#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

#2069 in Data structures

Download history 49/week @ 2024-02-19 47/week @ 2024-02-26 2/week @ 2024-03-04 13/week @ 2024-03-11 53/week @ 2024-04-01 7/week @ 2024-04-15

60 downloads per month
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