pub unsafe trait PointerChunkIndex<T>: PointerIndex<[T]> + TrustedChunkSizedCollection { }Expand description
Marker trait for collections that allow unsynchronized access to non-overlapping chunks of their elements through pointers.
The trait allows unsynchronized access to chunks of elements of a collection by allowing the creation of mutable pointers to chunks of elements from a shared reference to the collection and its index.
The user is responsible to avoid data races and to respect Rust’s aliasing rules (one or more shared references or exactly one mutable reference) when dereferencing pointers.
§Safety
Implementors of this trait must guarantee the following invariants:
- The collection contains
num_chunksnon-overlapping slices ofT, each of lenchunk_size. - For each collection of size
n, chunk indexes are defined from0ton - 1, each univocally identifying a chunk of elements in the collection as follows: a chunk of indexiincludes all elements from indexi * collection.chunk_size()included to(i + 1) * collection.chunk_size()excluded. - The collection implements
PointerIndex<[T]>where[T]is a chunk, so[T].len() == collection.chunk_size(), and where all the methods’ indexes refer to the chunk indexes as defined above.