Crates.io | handlebox |
lib.rs | handlebox |
version | 0.3.0 |
source | src |
created_at | 2017-12-16 19:03:25.989313 |
updated_at | 2017-12-16 19:17:57.808535 |
description | A map-like collection that reuses unused keys |
homepage | |
repository | https://github.com/pcsm/handlebox |
max_upload_size | |
id | 43318 |
size | 5,450 |
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.
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);