@ts-rust/std - v0.0.5
    Preparing search index...

    Function ok

    • Creates an Ok variant of a Result with a void value.

      Wraps undefined in an Ok, indicating a successful outcome with no value (void) for a checked Result.

      Type Parameters

      • E

        The type of the potential error.

      Parameters

      • value: void

        The void value (typically omitted or undefined).

      Returns Result<void, E>

      A Result containing undefined as Ok.

      const x = ok<string>();

      expect(x.isOk()).toBe(true);
      expect(x.unwrap()).toBeUndefined();
    • Creates an Ok variant of a Result containing the given value.

      Wraps the provided value in an Ok, indicating a successful outcome for a checked Result.

      Type Parameters

      • T

        The type of the value.

      • E

        The type of the potential error.

      Parameters

      • value: T

        The value to wrap in Ok.

      Returns Result<T, E>

      A Result containing the value as Ok.

      const x = ok<number, string>(42);

      expect(x.isOk()).toBe(true);
      expect(x.unwrap()).toBe(42);