Readonly errorOptional config: ErrorConfigThis method is unsafe, and should only be used in a test environments
takes a Result<T, E> and returns a E when the result is an Err,
otherwise it throws a custom object.
Optional _: ErrorConfigSimilar to map Except you must return a new Result.
This is useful for when you need to do a subsequent computation using the
inner T value, but that computation might fail.
Additionally, andThen is really useful as a tool to flatten a
Result<Result<A, E2>, E1> into a Result<A, E2> (see example below).
Similar to map Except you must return a new Result.
This is useful for when you need to do a subsequent async computation using
the inner T value, but that computation might fail. Must return a ResultAsync
The function that returns a ResultAsync to apply to the current
value
Maps a Result<T, E> to ResultAsync<U, E>
by applying an async function to a contained Ok value, leaving an Err
value untouched.
Used to check if a Result is an Err
true if the result is an Err variant of Result
Used to check if a Result is an OK
true if the result is an OK variant of Result
Maps a Result<T, E> to Result<U, E>
by applying a function to a contained Ok value, leaving an Err value
untouched.
the result of applying f or an Err untouched
Maps a Result<T, E> to Result<T, F> by applying a function to a
contained Err value, leaving an Ok value untouched.
This function can be used to pass through a successful result while handling an error.
Given 2 functions (one for the Ok variant and one for the Err variant)
execute the function that matches the Result variant.
Match callbacks do not necessitate to return a Result, however you can
return a Result if you want to.
match is like chaining map and mapErr, with the distinction that
with match both functions must have the same return type.
Takes an Err value and maps it to a Result<T, SomeNewType>.
This is useful for error recovery.
Emulates Rust's ? operator in safeTry's body. See also safeTry.
This method is unsafe, and should only be used in a test environments
Takes a
Result<T, E>and returns aTwhen the result is anOk, otherwise it throws a custom object.