• Takes the error value as an optional if the result is an Err, otherwise returns None.

    Type Parameters

    • E

    • T

    Parameters

    • res: Result<E, T>

      The source result.

    Returns Option<E>

    The error value if exists.

    Examples

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

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

Generated using TypeDoc