better-returns
    Preparing search index...

    Function replace_error

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

      Type Parameters

      • T

        The type of the successful value.

      • E

        The original type of the error value.

      • U

        The new type of the error value.

      Parameters

      • result: Result<T, E>

        The result whose error value to replace.

      • value: U

        The new error value to put into an Err result.

      Returns Result<T, U>

      A new Result with the replaced error value, or the original Ok.