pub fn scope_unbounded_with<'env, T, R, F, Init, Merge>(
initial: impl IntoIterator<Item = T>,
init: Init,
run: F,
merge: Merge,
) -> RExpand description
scope_unbounded, plus a per-drainer accumulator folded into a single return value.
Each drainer builds its own accumulator with init, run mutates it in place while processing
items, and the accumulators are combined pairwise with merge as drainers finish. merge must
be associative and commutative — drainers finish in a nondeterministic order, so the grouping
and ordering of the folds are not specified.
This exists so run can efficiently accumulate with minimal locking overhead managed by the
scope.
init is called potentially many times for each thread context.
Returns init() when no item is ever processed (e.g. an empty initial).
§Panics and aborts
Both ControlFlow::Break and a panic abort the scope, abandoning every queued-but-unstarted
item (see scope_unbounded). They differ in what comes back:
- On
Break, results accumulated before the abort are returned as usual; the abandoned items simply never contributed. - On a panic, the panic is re-raised after the join and all accumulated results are discarded — the return value is only produced on the normal path.