Function fromResult

  • Construct a ~Maybe Maybe from a ~Result Result<T, E>.

    If the Result is an Ok, wrap its value in Just. If the Result is an Err, throw away the wrapped E and transform to a ~Nothing Nothing.

    Type Parameters

    • T extends {}

      The type of the value wrapped in a Result.Ok and in the Just of the resulting Maybe.

    Parameters

    • result: Result<T, unknown>

      The Result to construct a Maybe from.

    Returns Maybe<T>

    Just if result was Ok or Nothing if it was Err.