always-panic - v0.10.1
    Preparing search index...

    Class Err<E>

    Method contract shared by Ok and Err, aligned with Rust std::result::Result.

    Result<T, E> is either success (Ok(T)) or failure (Err(E)). Implementations mirror the Rust combinator names and semantics; on failure, expect / unwrap / unwrapErr throw a JavaScript Error instead of panicking.

    Type Parameters

    • E

      Success (Ok) payload type.

    Implements

    Index

    Constructors

    Properties

    error: E

    Methods

    • Enables yield* res inside a result.gen body — the equivalent of Rust's ? operator.

      On Ok, yield* produces no yields and evaluates to the contained value. On Err, it yields the Err itself, which the surrounding result.gen / genSync / genAsync driver returns by reference (short-circuiting the rest of the body). Not meant to be iterated by anything other than those drivers.

      Returns Generator<Err<E>, never>

    • Returns res if this result is Ok, otherwise returns this Err.

      res is evaluated eagerly; prefer andThen when it comes from a function call that should run only after Ok.

      Parameters

      • _res: unknown

      Returns this

      res on Ok, or this on Err.

    • Calls fn if this result is Ok, otherwise returns this Err.

      Use to chain fallible steps that return another Result.

      Parameters

      • _fn: unknown

      Returns this

      The Result from fn, or this on Err.

    • Returns the contained Ok value.

      Prefer narrowing (isOk / isErr) or non-throwing helpers (unwrapOr, unwrapOrElse) when the Err case is expected.

      Parameters

      • message: string

        Included in the thrown Error when this result is Err (describe why you expected Ok, as in Rust's expect docs).

      Returns never

      The success value.

      When the result is Err.

    • Maps Result<T, E> to Result<U, E> by applying fn to the contained Ok value, leaving an Err untouched.

      Type Parameters

      • _

      Parameters

      • _fn: unknown

      Returns this

      A new Result with the mapped Ok value, or the original Err.

    • Maps Result<T, E> to Result<T, F> by applying fn to the contained Err value, leaving an Ok untouched.

      Type Parameters

      • E2

      Parameters

      • fn: (error: E) => E2

        Transforms the error value.

      Returns Err<E2>

      A new Result with the mapped Err value, or the original Ok.

    • Returns defaultValue if Err, or applies fn to the contained Ok value.

      Both arguments are evaluated eagerly; prefer mapOrElse when the fallback should run only on Err.

      Type Parameters

      • U1
      • _

      Parameters

      • defaultValue: U1

        Value returned when this result is Err.

      • _fn: unknown

      Returns U1