pendingErr
@ts-rust/std / Result / pendingErr
Function: pendingErr()
function pendingErr<T, E>(error): PendingResult<Awaited<T>, Awaited<E>>;
Defined in: packages/std/src/result/result.ts:403
Creates a PendingResult\<T, E\> that resolves to Err containing the awaited error.
Takes an error or promise and wraps its resolved result in an Err,
ensuring the error type is Awaited to handle any PromiseLike input.
Type Parameters
| Type Parameter | Description |
|---|---|
| The type of the potential value. |
| The type of the input error or promise. |
Parameters
| Parameter | Type | Description |
|---|---|---|
| | | The error or promise to wrap in Err. |
Returns
PendingResult<Awaited<T>, Awaited<E>>
A PendingResult resolving to Err with the awaited error.
Example
const x = pendingErr<number, string>("failure");
const y = pendingErr<string, number>(Promise.resolve(42));
expect(await x).toStrictEqual(err("failure"));
expect(await y).toStrictEqual(err(42));