Expand description
A segmented growable vector with stable pointers.
Unlike Vec, pushing new elements never invalidates pointers to existing elements.
This is achieved by storing elements in segments of exponentially growing sizes.
§Example
use segmented_vec::SegmentedVec;
let mut vec: SegmentedVec<i32, 4> = SegmentedVec::new();
vec.push(1);
vec.push(2);
// Get a pointer to the first element
let ptr = &vec[0] as *const i32;
// Push more elements - the pointer remains valid!
for i in 3..100 {
vec.push(i);
}
// The pointer is still valid
assert_eq!(unsafe { *ptr }, 1);Structs§
- Chunks
- An iterator over non-overlapping chunks of elements.
- Chunks
Exact - An iterator over exact-size chunks of elements.
- Drain
- A draining iterator for
SegmentedVec. - Into
Iter - An owning iterator over elements of a
SegmentedVec. - Iter
- An iterator over references to elements of a
SegmentedVec. - IterMut
- An iterator over mutable references to elements of a
SegmentedVec. - RChunks
- An iterator over non-overlapping chunks of elements, starting from the end.
- Segmented
Slice - An immutable slice view into a
SegmentedVec. - Segmented
Slice Mut - A mutable slice view into a
SegmentedVec. - Segmented
Vec - A segmented vector with stable pointers.
- Slice
Iter - An iterator over references to elements of a
SegmentedSlice. - Slice
Iter Mut - A mutable iterator over elements of a
SegmentedSliceMut. - Windows
- An iterator over overlapping windows of elements.