-
Notifications
You must be signed in to change notification settings - Fork 18k
proposal: iter: SeqError type, Throw function #67924
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
|
The worst name I came up with was I'm entirely open to a better name - |
Putting the
With Getting back to the
To recover from the panic, just use @AndrewHarrisSPU As I may have misinterpreted the goal of your proposal, would you mind further clarifying what problem you are trying to solve? If we are addressing different use cases, I will file another proposal then. |
I don't understand why it's |
Two details seemed to work out better for First, a Second, |
I don't understand why this machinery would be used instead of Seq2[T, error]. |
I tried to formulate some finesse here - I would not to want to coerce the decision against Seq2[T, error] and for Seq2[T, SeqError], but leave it more open-ended. The idea would be, an implementation can opt into exporting the What should be maintained invariantly is a static inference about errors in I think that invariant is useful as a hook for readability and analysis, and as a premise for iterator composition. For example, @jba's error function idea could be functionally derived from Seq2[T, SeqError] more confidently than from Seq2[T, error]. Or, I worry that it's possible to lose track of the invariant with |
This proposal has been declined as infeasible. |
Proposal Details
The proposed API is a definition of a
SeqError
, associated with an iteration or sequencing abnormality, located in theiter
package.SeqError
is an enriched error type with the following properties:errors.Unwrap
anderrors.Is
is supported.iter.Seq2[T, error]
anditer.Seq2[T, iter.SeqError]
, the latter says something usefully more narrow.Additionally, a
Throw
function synthesizing aSeqError
from an existing error is proposed.The obvious use case is that an iterator may
Throw
an error as aSeqError
where it would otherwise yield an error on an unhappy path. A quick sketch of where an iterator would throw:Implementation would be short:
Adopting this proposal would be asking APIs that export fallible iterators to consistently
Throw
, or otherwise provide something that statically or dynamically matchesSeqError
, where appropriate. Assuming no convergence on how iteration errors are handled, maybe it's worth asking that fallible iterators define an iteration error in a common way.The text was updated successfully, but these errors were encountered: