fn alloc_iter<T>(iter: impl ExactSizeIterator<Item = T>) -> &'static [T]
Expand description
Allocates a slice from an iterator and returns a reference with a static lifetime.
This function takes an iterator implementing ExactSizeIterator
, allocates a slice using elements from this iterator, and returns a reference to this slice with a 'static
lifetime.
It utilizes a thread-local storage arena (THR_ARENA
) to handle memory allocation.
Inside the thread-local arena, it calls alloc_slice_fill_iter
to allocate and fill the slice based on the provided iterator.
The memory address of this allocated slice is then manipulated as a mutable pointer, which is unsafely coerced into a reference with a static lifetime and returned.
This requires caution, as improper lifetime management may lead to undefined behavior.