#map #container #reuse

handlebox

A map-like collection that reuses unused keys

2 unstable releases

Uses old Rust 2015

0.3.0 Dec 16, 2017
0.2.0 Dec 16, 2017

#2220 in Data structures

Download history 68/week @ 2024-04-01 16/week @ 2024-04-08 13/week @ 2024-04-15 18/week @ 2024-04-22 27/week @ 2024-04-29 13/week @ 2024-05-06 57/week @ 2024-05-13 47/week @ 2024-05-20 15/week @ 2024-05-27 21/week @ 2024-06-03 24/week @ 2024-06-10 13/week @ 2024-06-17 18/week @ 2024-06-24 5/week @ 2024-07-01 12/week @ 2024-07-08 37/week @ 2024-07-15

73 downloads per month
Used in 4 crates (via simulacrum_mock)

MIT license

5KB
70 lines

Handlebox

Handlebox is a simple map-like collection that reuses unused keys. Right now it's hard-coded to use u32 keys.

To install, add this line to your Cargo.toml:

[dependencies]
handlebox = "0.3.0"

Note that Handlebox has not yet reached version 1.0, so the API may change drastically between releases.

Example

use handlebox::*;

// Creating
let mut c = HandleBox::new();

// Adding values
let h1 = c.add(888);

// Accessing values
assert_eq!(c.get(&h1).unwrap(), &888);

// Removing values
c.remove(&h1);

// You can access the internal BTreeMap<u32, V> with the .map field
assert_eq!(c.map.values().len(), 0);

No runtime deps