expect method

T expect(
  1. String message
)

Returns the held value of this Option if it is Some, or throws OptionError with the given message if this Option is None.

See also: Rust: Option::expect()

Implementation

T expect(String message) {
  return switch (this) {
    Some(:T v) => v,
    None() => throw OptionError(message, isExpected: true),
  };
}