expect method

T expect(
  1. String message
)

Returns the held value of this Result if it is Ok. Throws a ResultError with the given message and held Err value if this Result is Err.

See also: Rust: Result::expect()

Implementation

T expect(String message) {
  return switch (this) {
    Ok(:T v) => v,
    Err(:E e) => throw ResultError('$message: $e', isExpected: true),
  };
}