• Takes the success value as an optional if the result is an Ok, otherwise returns None.

    Type Parameters

    • E

    • T

    Parameters

    • res: Result<E, T>

      The source result.

    Returns Option<T>

    The success value if exists.

    Examples

    import { err, ok, optionOk, orElse } from "./result.ts";
    import { some, none } from "./option.ts";
    import { assertEquals } from "../deps.ts";

    assertEquals(optionOk(ok(2)), some(2));
    assertEquals(optionOk(err("nothing left")), none());

Generated using TypeDoc