Result
Index
Accessor
get
Type parameters
- V
getError
Returns the
error
if Result.Error, Option.None if Result.OkType parameters
- E
getOrElse
Returns the
value
if Result.Ok,getDefaultValue()
if Result.Error.Type parameters
- V
- VDefault
getOrThrow
Returns the
value
if Result.Ok, throwerror
if Result.Error.⚠ Impure function that may throw an error, its use is generally discouraged.
Type parameters
- V
Constructor
Error
Create a new
Error
object
Ok
Create a new
Ok
object
Type
hasInstance
Return
true
ifanyValue
is Result.Ok or Result.Error
isError
Return
true
ifanyValue
is Result.ErrorType parameters
- V
- E
isOk
Return
true
ifanyValue
is 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
fn
if the result is Result.Ok, otherwise returns the Result.Error value of self. This function can be used for control flow based onResult
values.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
match
Return
matchers.Ok(value)
ifresult
isOk
, otherwisematchers.Error(error)
Type parameters
- Value
- Error
- Return
orElse
Calls
fn
if 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
value
if Result.Ok, Option.None if Result.Error