Result
Index
Accessor
get
Type parameters
- V
getError
Returns the
errorif Result.Error, Option.None if Result.OkType parameters
- E
getOrElse
Returns the
valueif Result.Ok,getDefaultValue()if Result.Error.Type parameters
- V
- VDefault
getOrThrow
Returns the
valueif Result.Ok, throwerrorif Result.Error.⚠ Impure function that may throw an error, its use is generally discouraged.
Type parameters
- V
Constructor
Error
Create a new
Errorobject
Ok
Create a new
Okobject
Type
hasInstance
Return
trueifanyValueis Result.Ok or Result.Error
isError
Return
trueifanyValueis Result.ErrorType parameters
- V
- E
isOk
Return
trueifanyValueis Result.OkType parameters
- V
- E
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.Type parameters
- VFrom
- EFrom
- VTo
- ETo
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.Type parameters
- VFrom
- VTo
- E
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.Type parameters
- V
- EFrom
- ETo
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.Type parameters
- VFrom
- EFrom
- VTo
- ETo
tryCall
Returns
Ok(block()). If an error was thrown then it returnsError(onError(<<thrown error>>))insteadType parameters
- V
- E
Returns the
valueif Result.Ok, Option.None if Result.Error