Function inplace_it::alloc_array
source · pub fn alloc_array<T, R>(
size: usize,
init: impl Fn(usize) -> T,
consumer: impl Fn(&mut [T]) -> R
) -> R
Expand description
alloc_array
is used when inplace_array
realize that the size of requested array of T
is too large and should be replaced in the heap.
It allocates a vector with size
elements and fills it up with help of init
closure
and then pass a reference to a slice of the vector into the consumer
closure.
consumer
’s result will be returned.