https://github.com/vi/slab_typesafe
A type-safe wrapper for Rust's "slab" data structure
https://github.com/vi/slab_typesafe
rust slab typesafe
Last synced: about 1 year ago
JSON representation
A type-safe wrapper for Rust's "slab" data structure
- Host: GitHub
- URL: https://github.com/vi/slab_typesafe
- Owner: vi
- Created: 2017-12-27T21:51:05.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-01-07T17:00:58.000Z (over 7 years ago)
- Last Synced: 2025-03-28T21:03:11.764Z (over 1 year ago)
- Topics: rust, slab, typesafe
- Language: Rust
- Homepage:
- Size: 11.7 KB
- Stars: 5
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# slab_typesafe
A type-safe wrapper from Rust's "slab" data structure
Prevents using [slab](https://crates.io/crates/slab) with obviously wrong keys:
```rust
#[macro_use]
extern crate slab_typesafe;
declare_slab_token!(StringHandle1);
declare_slab_token!(StringHandle2);
let mut slab1 : Slab = Slab::new();
let mut slab2 : Slab = Slab::new();
let hello = slab1.insert("hello");
let world = slab2.insert("world");
slab1[world]; // the type `Slab` cannot be indexed by `StringHandle2`
slab2.remove(hello); // expected struct `StringHandle2`, found struct `StringHandle1`
```rust