[Feature Request] [stdlib] [proposal] Add ErrorReg
, Result
, and ResultReg
types
#2748
Open
1 task done
Labels
enhancement
New feature or request
mojo-repo
Tag all issues with this label
needs-discussion
Need discussion in order to move forward
Review Mojo's priorities
What is your request?
Result is basically a copy paste of Optional just with an error attribute.
"""Defines Result, a type modeling a value which may or may not be present.
With an Error in the case of failure.
Result values can be thought of as a type-safe nullable pattern.
Your value can take on a value or
None
, and you need to checkand explicitly extract the value to get it out.
And if more information about the returned Error is wanted it is available.
A Result with an Error cal also be retuned early:
What is your motivation for this change?
Better Error handling than raising and giving people tools to write nicer code
Any other details?
I skimmed over the Error struct's code and it seems it can be done replacing its fields with just a StringLiteral (?)
The text was updated successfully, but these errors were encountered: