shared_slab 0.1.0

Data structure with shared insertion
Documentation
  • Coverage
  • 0%
    0 out of 15 items documented0 out of 14 items with examples
  • Size
  • Source code size: 19.38 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 4.67 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • TheOnlyMrCat

shared_slab

This crate provides a single data type, Slab, which is very similar in concept to that provided by the slab or sharded-slab crates.

The key difference of this crate as compared to the others can be summed up in the function signatures:

pub fn get(&self, key: usize) -> Option<&T>
pub fn insert(&self, value: T) -> usize
pub fn insert_and_get(&self, value: T) -> (usize, &T)
pub fn remove(&mut self, key: usize) -> T

Or, in words, shared insertion while allowing shared access to the values contained within. (slab requires mutable access for insertion, and sharded-slab doesn't provide direct &T references to contained data)

As for use-cases, this structure is mainly useful for memoizing and reusing resources, in a pattern of:

pub fn add_resource(&self, resource_descriptor: Descriptor) -> &Resource