Result
Index
Accessor
get
getError
Returns the
errorif Result.Error, Option.None if Result.Ok
getOrElse
Returns the
valueif Result.Ok,getDefaultValue()if Result.Error.
getOrThrow
Returns the
valueif Result.Ok, throwerrorif Result.Error.⚠ Impure function that may throw an error, its use is generally discouraged.
Constructor
Error
Create a new
Errorobject
Ok
Create a new
Okobject
Type
hasInstance
Return
trueifanyValueis Result.Ok or Result.Error
isError
Return
trueifanyValueis Result.Error
isOk
Return
trueifanyValueis Result.Ok
Other
Error
Type parameters
- E
readonlyerror
The error value
readonlyok
false only for Error objects
Ok
Type parameters
- V
readonlyok
true only for Ok objects
readonlyvalue
The success value
andThen
Calls
fnif the result is Result.Ok, otherwise returns the Result.Error value of self. This function can be used for control flow based onResultvalues.
map
Maps a
Result<ValueFrom, Error>toResult<ValueTo, Error>by applying a function to a contained Result.Ok value, leaving a Result.Error value untouched. This function can be used to compose the results of two functions.
mapError
Maps a
Result<Value, ErrorFrom>toResult<Value, ErrorTo>by applying a function to a contained Result.Error value, leaving a Result.Ok value untouched. This function can be used to pass through a successful result while handling an error.
orElse
Calls
fnif the result is Result.Error, otherwise returns the Result.Ok value of self. This function can be used for control flow based on result values.
tryCall
Returns
Ok(block()). If an error was thrown then it returnsError(onError(<<thrown error>>))instead
Returns the
valueif Result.Ok, Option.None if Result.Error