Replies: 1 comment 3 replies
-
Thanks for your proposal. Let's start from signature: public static implicit operator Result<T>(in Exception reason) No need to use in modifier because public static implicit operator Result<T>(T result);
public static implicit operator Result<T>(Exception reason); Which one should be used if |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm exploring currently the concept of Result datatype in context of bindings to a low-level C-API. I've implemented a simple result type for this as a ref struct and I'm looking now into adopting the dotnext result type instead.
What I 've added to my implemention was a conversion operator from Exception:
This allows me to alternatively return a T or an Exception:
For me this feels pretty sweet because I don't have to explicitly put the T in the error generation:
Result.FromException<int>(new Exception("fail"))
Has something like this been discussed and thrown out?
Any opinions on that?
Beta Was this translation helpful? Give feedback.
All reactions