toOption method

Option<T> toOption()

Convert to Option, where Ok becomes Some and Err becomes None.

Implementation

@pragma('vm:prefer-inline')
Option<T> toOption() {
  if (isOk) {
    return Some((this as Ok<T, E>).value);
  }
  return const None();
}