Function rayon::iter::collect::special_extend

source ·
pub(super) fn special_extend<I, T>(pi: I, len: usize, v: &mut Vec<T>)
where I: ParallelIterator<Item = T>, T: Send,
Expand description

Collects the results of the iterator into the specified vector.

Technically, this only works for IndexedParallelIterator, but we’re faking a bit of specialization here until Rust can do that natively. Callers are using opt_len to find the length before calling this, and only exact iterators will return anything but None there.

Since the type system doesn’t understand that contract, we have to allow any ParallelIterator here, and CollectConsumer has to also implement UnindexedConsumer. That implementation panics unreachable! in case there’s a bug where we actually do try to use this unindexed.