-
Notifications
You must be signed in to change notification settings - Fork 313
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
.try_collect()
for Iterator<Option>
#951
Comments
But in #844 we discussed fallible iterators and we might generalize (amongst other things) |
you're right, I missed the Vec part. Here is an example code that would be nice if it worked:
|
Our |
It's literally impossible to make such a method that's lazy. And if you're fine with
Perhaps one of the patterns in https://doc.rust-lang.org/stable/rust-by-example/error/iter_result.html#iterating-over-results would be helpful for you? |
So yeah, there is |
I ended up replacing None with Error inside the map, then I used |
That seems more hacky than |
.try_collect()
is for turningIterator<Result<T>>
intoResult<Iterator<T>>
. Can you create an equivalent method that turnsIterator<Option<T>>
intoOption<Iterator<T>>
? Or perhaps implement it as a generic, as part oftry_collect()
?The use case is for creating programs that never crash at runtime (where error conditions are passed to the logs, and Result converted to Option, and program is continuing without interruption).
The text was updated successfully, but these errors were encountered: