Skip to content

Add ForEachErr() func - #980

Open
mai7star wants to merge 1 commit into
samber:masterfrom
mai7star:feature/for_each_err
Open

Add ForEachErr() func#980
mai7star wants to merge 1 commit into
samber:masterfrom
mai7star:feature/for_each_err

Conversation

@mai7star

Copy link
Copy Markdown
Contributor

Description:
This PR introduces ForEachErr, a utility function that iterates over a collection and invokes a provided callback for each item. If the callback returns a non-nil error, ForEachErr stops processing and returns that error immediately. This makes it easier to perform per-item operations that may fail and to propagate errors without manual loop boilerplate.

Why:

  • Reduces repetitive boilerplate for error-aware iteration.
  • Provides a clear and consistent pattern for early-exit item processing.

What changed:

  • Adds the ForEachErr implementation.
  • Adds accompanying unit tests and/or examples demonstrating typical usage.
  • No changes to existing public APIs or behavior beyond adding this new helper.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant