Closed BooleanCat closed 1 month ago
@jlc-christie Can you think of a better name than CollectErr
?
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 100.00%. Comparing base (
2c10c17
) to head (6dee8f3
).
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
@jlc-christie Can you think of a better name than
CollectErr
?
I think that makes sense since we're not being generic over the right side iterator, although do you already support a CollectLeft and CollectRight? Might be beneficial to add those and then defer to CollectRight with a type constraint for CollectErr implementation?
@jlc-christie Can you think of a better name than
CollectErr
?I think that makes sense since we're not being generic over the right side iterator, although do you already support a CollectLeft and CollectRight? Might be beneficial to add those and then defer to CollectRight with a type constraint for CollectErr implementation?
Currently the way to collect the two values separately would be to do something like:
lines, errs := itx.LinesString(reader).Unzip()
return lines.Collect(), errors.Join(errs.Collect()...)
Please provide a brief description of the change.
A common form of iteratoring with an
iter.Seq
will be pairs of values where the right side is an error (for exampling iterating over lines in anio.Reader
.CollectErr
is a helper that will collect the left values from the iterator and the righterror
values will be joined into a single error.Which issue does this change relate to?
None.
Contribution checklist.
Additional context
I've also added some helper functions to extend the power of this change.op.Apply{Left/Right}
are to be used withMap2
in order to apply a function to only left or right values. I'm consideringFilter{Left/Right}
also.