Skip to content
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

FromFallibleIterator trait is useless except for wrappers #28

Open
TheQuantumPhysicist opened this issue Sep 9, 2022 · 2 comments
Open

Comments

@TheQuantumPhysicist
Copy link

TheQuantumPhysicist commented Sep 9, 2022

Perhaps this is a design decision, I'm not sure, but FromFallibleIterator cannot be implemented for custom types because it's not a generic over the error type except in a very way, or maybe I don't understand how to use it. This is a design decision (?) that I do not understand.

Instead of having a generic with a trait bound Into<I::Error> (meaning, we can use any error type that is compatible with the iterator error type), we can only return Result<Self, I::Error> very specifically. And given that rust has nothing like C++'s sfinae to do compile-time generalized conversions if they succeed, there's absolutely no way to call any custom fallible function inside any from_fallible_iter implementation, because nothing can convert to I::Error even if we wanted to... no matter what we do.

So, the only thing we can do with this function is iterate and return the result from the iterator, making this function only useful for struct wrappers, which quite-frankly could've been achieved with some kind of derive instead of a manual implementation that just iterates and uses the try operator ? on every iteration.

It would be great to find a solution for this. I think the right solution would be to add a generic Error parameter to the trait, bounded by Into<I::Error>, but I'm probably not expert enough in rust type gameplay to be certain about this suggestion.

@tamird
Copy link
Contributor

tamird commented May 3, 2023

FromFallibleIterator was removed in #19.

@tamird
Copy link
Contributor

tamird commented May 16, 2023

@dpc this can probably be closed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants