|
|
|
|
|
by ww520
3400 days ago
|
|
> I think I'd still prefer to have a named type, but the standard library should provide a standard way to construct that type. Having ad-hoc error union Result per function make it lightweight, and less friction in writing code. I would go one step further, let the compiler build the error union automatically. fn func1() -> Result<MyStruct, _> {
let foo = foo()?; // might return Error1
let bar = bar()?; // might return Error2
...
}
The compiler infers the list of possible error types returning from the functions. Func1() would automatically have the return signature of Result<MyStruct, Error1 | Error2>.Make the type inference to good use. |
|