Tryable
public protocol TryableProtocol enabling the try expr operator.
Output is the success value the operator yields; Residual is the
"residual" — typically an Err variant, a None, or a typed error —
that gets propagated. The compiler lowers try x to roughly
match x.tryExtract() { .Continue(v) => v, .Break(r) => return Self.fromResidual(r) },
which is why the enclosing function's return type must conform to
FromResidual[Residual].
Examples
// Optional and Result both conform; `try` chains them seamlessly.
func parseAndDouble(s: String) -> Int64? {
let n = try Int64.parse(s); // .None short-circuits the whole function
.Some(n * 2)
}Associated Types
type Output
type OutputThe value produced by try expr on success.
type Residual
type ResidualThe residual carried out of try expr on failure.
Methods
consuming func tryExtract() -> ControlFlow[Output, Residual]
consuming func tryExtract() -> ControlFlow[Output, Residual]Splits self into the success value or the early-return residual.
Defined in lang/std/core/error.ks