This PR adds support for a new generic primitive type named Result.
It is syntactically equivalent to a Dictionary, but uses the Result keyword instead.
Result is a Slice2 only feature. It can be used anywhere a type can be.
It is logically equivalent to a compact enum with 2 variants for 'ok' and 'error'.
Internally in the compiler, I named it ResultType, since Result is a heavily used type in Rust.
Deviations from the original proposal (#682)
In the original proposal, we wanted to support tuples in the Ok type:
Result<(a: bool, tag(2), b: string?), MyError>
However this implementation does not support this, since we never added support for first-class tuples to Slice.
Both type parameters for Result must be Slice types.
We can always change this in the future, but note there is no lack of functionality.
Users must simply convert their tuple into a struct, and then that struct can be used.
This PR adds support for a new generic primitive type named
Result
. It is syntactically equivalent to aDictionary
, but uses theResult
keyword instead.Result
is a Slice2 only feature. It can be used anywhere a type can be. It is logically equivalent to a compact enum with 2 variants for 'ok' and 'error'.Internally in the compiler, I named it
ResultType
, sinceResult
is a heavily used type in Rust.Deviations from the original proposal (#682)
In the original proposal, we wanted to support tuples in the
Ok
type:However this implementation does not support this, since we never added support for first-class tuples to Slice. Both type parameters for
Result
must be Slice types.We can always change this in the future, but note there is no lack of functionality. Users must simply convert their tuple into a struct, and then that struct can be used.