Closed hawkw closed 2 years ago
Thanks for the review @taiki-e. I'd like to get @carllerche's opinion on this as well before merging, since it's different from how he originally proposed implementing Valuable
for results.
ping @carllerche, any thoughts on this?
Closes #18
This PR adds
Valuable
andEnumerable
implementations forResult<T, E>
whereT
andE
areValuable
.@carllerche's comment in https://github.com/tokio-rs/valuable/issues/18#issue-890512640 suggested that
Result
s should "flatten" the inner values rather than implementingEnumerable
.However, this PR does implement
Enumerable
. This is because simply flatteningResult
s to theOk
orErr
value would make it impossible for theVisit
or to determine if a givenResult
is anOk
orErr
value, which seems quite important for some use cases. As I described in https://github.com/tokio-rs/valuable/issues/18#issuecomment-938905149:If others disagree that this is the right approach, I'd be happy to discuss it further, but I thought I'd go ahead and open a PR in the meantime. :)