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 include a implicit operator as well? i was working on a simular solution/problem.
Where I am calling a function that returns Result<T, TE>. But my method signature should return a Maybe. So in the case that result.isFailure it needs to convert. Now I have:
But i guess the implicit converter would even be better.
publicstaticclassMaybeExtensions{// Implicit conversion operator from Result<T, TE> to Maybe<T>publicstaticimplicitoperatorMaybe<T>(Result<T,TE>result){returnresult.IsSuccess?Maybe<T>.From(result.Value):Maybe<T>.None;}}
I think i cannot add this directly in my code, can I?
Activity
vkhorikov commentedon Jan 27, 2024
Yes, looks good. Feel free to submit a PR please.
RoelantM commentedon Sep 18, 2024
perhaps include a implicit operator as well? i was working on a simular solution/problem.
Where I am calling a function that returns Result<T, TE>. But my method signature should return a Maybe. So in the case that result.isFailure it needs to convert. Now I have:
But i guess the implicit converter would even be better.
I think i cannot add this directly in my code, can I?
vkhorikov commentedon Sep 28, 2024
The lack of the implicit conversion is intentional. Check out this article: https://khorikov.org/posts/2021-11-08-converting-result-to-maybe/