@adviser/cement - v0.0.0
    Preparing search index...

    Class Result<T, E>Abstract

    Result type for representing success (Ok) or failure (Err) values.

    Result is a type-safe way to handle operations that can fail, similar to Rust's Result type. It forces explicit handling of both success and error cases without throwing exceptions.

    function divide(a: number, b: number): Result<number> {
    if (b === 0) {
    return Result.Err('Division by zero');
    }
    return Result.Ok(a / b);
    }

    const result = divide(10, 2);
    if (result.isOk()) {
    console.log('Result:', result.unwrap());
    } else {
    console.error('Error:', result.unwrap_err());
    }

    Type Parameters

    • T

      The type of the success value

    • E = Error

      The type of the error (default: Error)

    Hierarchy (View Summary)

    Index

    Constructors

    Methods