Crate segmented_vec

Crate segmented_vec 

Source
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.
ChunksExact
An iterator over exact-size chunks of elements.
Drain
A draining iterator for SegmentedVec.
IntoIter
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.
SegmentedSlice
An immutable slice view into a SegmentedVec.
SegmentedSliceMut
A mutable slice view into a SegmentedVec.
SegmentedVec
A segmented vector with stable pointers.
SliceIter
An iterator over references to elements of a SegmentedSlice.
SliceIterMut
A mutable iterator over elements of a SegmentedSliceMut.
Windows
An iterator over overlapping windows of elements.