Function toOkOrErr

  • Transform the Maybe into a Result, using the wrapped value as the Ok value if Just; otherwise using the supplied error value for Err.

    Type Parameters

    • T

      The wrapped value.

    • E

      The error type to in the Result.

    Parameters

    • error: E

      The error value to use if the Maybe is Nothing.

    • maybe: Maybe<T>

      The Maybe instance to convert.

    Returns Result<T, E>

    A Result containing the value wrapped in maybe in an Ok, or error in an Err.

  • Transform the Maybe into a Result, using the wrapped value as the Ok value if Just; otherwise using the supplied error value for Err.

    Type Parameters

    • T

      The wrapped value.

    • E

      The error type to in the Result.

    Parameters

    • error: E

      The error value to use if the Maybe is Nothing.

    Returns (maybe: Maybe<T>) => Result<T, E>

    A Result containing the value wrapped in maybe in an Ok, or error in an Err.