better-returns
    Preparing search index...

    Function replace

    • Replaces the successful value of an Ok result with a new value. If the result is Ok, a new Ok result with the provided value is returned. If the result is Err, it is returned unchanged.

      Type Parameters

      • T

        The original type of the successful value.

      • E

        The type of the error value.

      • U

        The new type of the successful value.

      Parameters

      • result: Result<T, E>

        The result whose successful value to replace.

      • value: U

        The new value to put into an Ok result.

      Returns Result<U, E>

      A new Result with the replaced successful value, or the original Err.