You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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 returnResult<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 anyfrom_fallible_iter
implementation, because nothing can convert toI::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.The text was updated successfully, but these errors were encountered: