3 ms·
Yeah, it's frustrating that there's no syntax for this. It could even be syntactic sugar; in this case if you had: type FooOrBarOrError = Foo | Bar | Error
by kelnos 1y ago
Yeah, it's frustrating that there's no syntax for this. It could even be syntactic sugar; in this case if you had:
type FooOrBarOrError = Foo | Bar | Error;
Then that could desugar to:
enum FooOrBarOrError {
Foo(Foo),
Bar(Bar),
Error(Error),
}
And it could also implement From for you, so you can easily get a FooOrBarOrError from a Foo, Bar, or Error; as well as implementing Display, StdError, etc. if the components already implement them.
I actually wonder if you could implement this as a proc macro...