4 ms·
Untagged unions lack the ability to model "the success value is a string and the error is a string", right?
by tubthumper8 2y ago
Untagged unions lack the ability to model "the success value is a string and the error is a string", right?
- rto_victim 2y agoThat's correct. In your case you can either model it with a sum type or wrap each variant in its own type and take the union of them. Example: enum Result { Success(String), Error(String), } struct Success(String); struct Error(String); type Result = Success | Error;