-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
C-tracking-issueCategory: A tracking issue for a feature request, i.e: not implemented / a PR.Category: A tracking issue for a feature request, i.e: not implemented / a PR.
Description
Provides iterator methods for items that are fallible.
This allows for useful patterns like:
def writeln(out: IO[str], content: str) -> Result[None, OsError]:
# handle io read/write that may fail.
out.write(content + '\n')
return Ok(None)
data = Vec(["hi", "mother"])
res = data.iter().try_for_each(lambda x: writeln(sys.stderr, x))
assert res.is_ok() # is ok, unless `writeln` causes an Err.Public API
class Iterator[Item]:
def try_for_each[E](self, f: Fn[[Item], Result[None, E]]) -> Result[None, E]: ...
def try_find(self, f: Fn[[Item], Result[Item, None]]) -> Result[Option[Item], None]: ...
def try_collect(self) -> Option[MutableSequence[Item]] where self yield Option[Item]: ...Steps / History
- Implementation: "PR LINK"
- Adjusted documentation
- Tested
- Changelog added
Unresolved Questions
Metadata
Metadata
Assignees
Labels
C-tracking-issueCategory: A tracking issue for a feature request, i.e: not implemented / a PR.Category: A tracking issue for a feature request, i.e: not implemented / a PR.