toOption method
Converts this result into an Option.
Converts Ok to Some and Err to None, discarding error information. Use this when you only care whether a value exists, not why it failed. If you need the error information, keep it as a Result.
Example:
final option = result.toOption(); // Option<T>
final value = option.unwrapOr(defaultValue);
Implementation
Option<T> toOption() => switch (this) {
Ok(:final value) => .some(value),
Err() => const .none(),
};