Maybe<T>.fromResult constructor

Maybe<T>.fromResult(
  1. Result<T> input
)

Factory for helping building a Maybe from a Result input. It produces a Nothing if the input is Failure, and a Just if the input is Success

Implementation

factory Maybe.fromResult(Result<T> input) {
  return input.handle(
    onSuccess: (data) => Just<T>(data),
    onFailure: (_) => Nothing<T>(),
  );
}