Other Functions
requireTrue
Returns the specified error if the job-wrapped value is false
.
requireFalse
Returns the specified error if the job-wrapped value is true
.
requireSome
Converts an job-wrapped Option to a Result, using the given error if None.
requireNone
Converts an job-wrapped Option to a Result, using the given error if Some.
requireValueSome
Converts an job-wrapped ValueOption to a Result, using the given error if ValueNone.
requireValueNone
Converts an job-wrapped ValueOption to a Result, using the given error if ValueSome.
requireEqual
Returns Ok if the job-wrapped value and the provided value are equal, or the specified error if not. Same as requireEqualTo
, but with a parameter order that fits normal function application better than piping.
requireEqualTo
Returns Ok if the job-wrapped value and the provided value are equal, or the specified error if not. Same as requireEqual
, but with a parameter order that fits piping better than normal function application.
requireEmpty
Returns Ok if the job-wrapped sequence is empty, or the specified error if not.
requireNotEmpty
Returns Ok if the job-wrapped sequence is non-empty, or the specified error if not.
requireHead
Returns the first item of the sequence if it exists, or the specified error if the sequence is empty
setError
Replaces an error value of an job-wrapped result with a custom error value
withError
Replaces a unit error value of an job-wrapped result with a custom error value. Safer than setError
since you're not losing any information.
defaultValue
Extracts the contained value of an job-wrapped result if Ok, otherwise uses the provided value.
defaultWith
Extracts the contained value of an job-wrapped result if Ok, otherwise evaluates the given function and uses the result.
ignoreError
Same as defaultValue
for a result where the Ok value is unit. The name describes better what is actually happening in this case.
tee
If the job-wrapped result is Ok, executes the function on the Ok value. Passes through the input value unchanged.
teeError
If the job-wrapped result is Error, executes the function on the Error value. Passes through the input value unchanged.
teeIf
If the job-wrapped result is Ok and the predicate returns true for the wrapped value, executes the function on the Ok value. Passes through the input value unchanged.
teeErrorIf
If the job-wrapped result is Error and the predicate returns true for the wrapped value, executes the function on the Error value. Passes through the input value unchanged.
sequenceJob
Converts a Result<Job<'a>, 'b>
to Job<Result<'a, 'b>>
.
Last updated