-
Notifications
You must be signed in to change notification settings - Fork 782
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
Implement IntoPyObject for Result<T, E> where E: Into<PyErr>
#4782
Comments
That's a very smart idea, and having support for fallible iterators would be a nice usability improvement. I also was wondering about having Another interesting improvement (internally) by having this proposed implementation for results is that we might be able to remove a lot of complex ok wrapping (probably in 0.25 when the removal of IntoPy is completed). Ultimately this isn't necessary though for end user experience so shouldn't affect the decision. A downside of this implementation would be that users can do weird stuff like pass results to Would love to hear others' opinions and thoughts on this one. |
Its a shame that |
This leaves very mixed feelings for me as well. I think it's quite valuable that you are forced to deal with the error. Sure most of the time it will just be bubbled up, but that's a deliberate choice and clearly visible in the code. If we allow passing the results directly this can easily happen by accident. And because there is nothing in the code distinguishing it from the infallible case, it makes it pretty hard to discover cases that return early/may deserve manual error handling. |
An other option could be to let the |
That seems potentially viable to explore. I was reminded the other day that currently The downside of a trait abstraction is that it's harder for new users to figure out how to use the constructor. We should weigh this up against just having multiple methods - what is easier to document and to read? |
It would be nice to have this implemented so one could use
PyList::new
,PyTuple::new
&PySet::new
with fallible iterators. One quick look into the source code showed me that the callback conversion code needs adjusting to make this possible (if possible at all).Does someone have an idea if this is feasible or wanted at all before I jump in this rabbit hole to implement this?
Thanks in advance.
The text was updated successfully, but these errors were encountered: