Very simple Rust library useful when you want stronger type guarantees than Slab's usize
keys. Generates TSlab(Slab<T>)
that accepts TKey
instead of usize
. TVacantEntry(VacantEntry<T>)
is also generated along the same lines.
```rust use wrapped_slab::WrappedSlab;
struct TestUnitStruct(String);
fn main() { let mut slab = TestUnitStructSlab::default(); let key: TestUnitStructKey = slab.insert(TestUnitStruct("testing".into())); let val: Option<&TestUnitStruct> = slab.get(key); let nextentry: TestUnitStructVacantEntry = slab.vacantentry(); let nextkey: TestUnitStructKey = nextentry.key(); let nextentryref: &mut TestUnitStruct = nextentry.insert(TestUnitStruct(format!("{nextkey:?}")));
// See wrapped_slab/tests/ for more examples
} ```
This is a very early version, however the aim is to just translate the Slab API 1-1. Currently the only things missing are Iter, IterMut, drain, and retain.