Thanks to @thejoshwolfe for this idea.
Before:
/// Use `span` instead of slicing this directly, because if you don't
/// specify the end position of the slice, this will potentially give
/// you uninitialized memory.
items: Slice,
len: usize,
allocator: *Allocator,
After:
/// It's OK to use this field! It's the slice of valid objects.
items: Slice,
capacity: usize,
allocator: *Allocator,
This requires ArrayList implementation to do some unsafe slicing when dealing with memory, but it will be encapsulated. No more need for callers to use at, toSlice, span or anything like that, they'll be able to access items directly.
I apologize to everyone for not doing it this way originally.
taking this
Should there be a len() function?
For example: table_entry.attrs.items.len vs table_entry.attrs.len().
Most helpful comment
taking this