https://github.com/pcsm/handlebox
A map-like collection that reuses unused keys
https://github.com/pcsm/handlebox
rust rust-library
Last synced: about 1 month ago
JSON representation
A map-like collection that reuses unused keys
- Host: GitHub
- URL: https://github.com/pcsm/handlebox
- Owner: pcsm
- License: mit
- Created: 2017-12-16T18:50:44.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-02-20T22:02:20.000Z (over 8 years ago)
- Last Synced: 2024-08-08T21:49:21.941Z (almost 2 years ago)
- Topics: rust, rust-library
- Language: Rust
- Size: 9.77 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Handlebox [](https://docs.rs/handlebox/) [](https://crates.io/crates/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:
```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
```rust
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 with the .map field
assert_eq!(c.map.values().len(), 0);
```