Function stackalloc_with_iter

Source
pub fn stackalloc_with_iter<I, T, U, F>(size: usize, iter: I, callback: F) -> U
where F: FnOnce(&mut [T]) -> U, I: IntoIterator<Item = T>,
Expand description

Collect an iterator into a stack allocated buffer up to size elements, call callback with this buffer, and then drop and deallocate the buffer.

See stackalloc().

ยงSize

We will only take up to size elements from the iterator, the rest of the iterator is dropped. If the iterator yield less elements than size, then the slice passed to callback will be smaller than size and only contain the elements actually yielded.