conc
conc copied to clipboard
fix: collect results after last error in ResultErrorPool
Fixes #156
Problem
ResultErrorPool.Wait() drops all results that come after the last errored task:
p := pool.NewWithResults[int]().WithErrors().WithMaxGoroutines(1)
p.Go(func() (int, error) { return 1, nil })
p.Go(func() (int, error) { return 2, errors.New("err") })
p.Go(func() (int, error) { return 3, nil })
got, _ := p.Wait()
// Got: [1]
// Expect: [1, 3]
The collect method's filtering loop appends segments between errored indices but never appends the tail segment after the last error.
Fix
Append the tail segment (results[lastErrored+1:]) after the loop.
Regression test added.
All existing tests pass.