0.2.4 Update
SliceMap is a project driven by another personal project, and its design follows the needs of that project. As a result, I had to go back to the idea of a Generic SliceMap that uses a Storage trait to pick different Storage structs.
Instead of [SliceMap] you should use the new type aliases, [SlotSliceMap] for SlotMap storage, [SecSliceMap] for SecondaryMap and [SparseSliceMap] for SparseSecondaryMap respectively.
To allow using [SparseSecondaryMap] this crate is not "no_std" anymore, but I plan to make that an optional feature and restore its no_std status!
Description
[SliceMap] and its type aliases provides a container that allows iterating directly all of its items, or iterating through non-overlapping slices of varying sizes. You can only insert new items in groups that will become a new slice.
Example
A good use would be storing the points for polygons with different point counts, but in a way where all those points are laid out continuously in memory. Each slice of points can be iterated separately and is effectively a new polygon. Drawing all polygons at once can be very CPU cache-friendly.
Here's a simpler example with i32 values:
use SlotSliceMap;
new_key_type!
let mut slices = default;
// Adding items returns a SliceKey
let _a = slices.add_items;
let b = slices.add_items;
let c = slices.add_items;
// Iterating over slices
let mut slice_iter = slices.iter_slices;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
drop;
// Iterating over all items
let mut i = 1;
for item in slices.iter_items
// Removing slices removes all of their items,
// but other keys are still valid!
slices.remove_slice;
let slice_c = slices.get_slice.unwrap;
assert_eq!;
let mut slice_iter = slices.iter_slices;
assert_eq!;
assert_eq!;