Result
Companion object for Result type
Attributes
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
Result.type
Members list
Type members
Classlikes
Attributes
- Supertypes
-
class AnyValtrait Matchableclass Any
Types
Represents a successful Result.
Represents a successful Result.
Attributes
Value members
Concrete methods
Creates a Result from an expression that might throw an exception.
Creates a Result from an expression that might throw an exception.
Type parameters
- A
-
The type of the successful result
Value parameters
- expr
-
The expression to evaluate
Attributes
- Returns
-
A Result containing either the successful value or a Panic with the caught exception
Collects a sequence of Results into a single Result containing a sequence of successful values.
Collects a sequence of Results into a single Result containing a sequence of successful values.
Type parameters
- A
-
The type of the successful values
- E
-
The type of the error
Value parameters
- seq
-
The sequence of Results to collect
Attributes
- Returns
-
A Result containing either a sequence of successful values or the first encountered error
Creates a failed Result.
Creates a failed Result.
Type parameters
- A
-
The type of the successful value (not used in this case)
- E
-
The type of the error
Value parameters
- error
-
The error value
Attributes
- Returns
-
A failed Result
Converts an Either to a Result.
Converts an Either to a Result.
Type parameters
- A
-
The type of the successful value (Right value)
- E
-
The type of the error (Left value)
Value parameters
- either
-
The Either to convert
Attributes
- Returns
-
A Result equivalent to the input Either
Converts a Try to a Result.
Converts a Try to a Result.
Type parameters
- A
-
The type of the successful value
Value parameters
- t
-
The Try to convert
Attributes
- Returns
-
A Result equivalent to the input Try
Creates a Result representing a panic situation.
Creates a Result representing a panic situation.
Type parameters
- A
-
The type of the successful value (not used in this case)
- E
-
The type of the error (not used in this case)
Value parameters
- exception
-
The exception causing the panic
Attributes
- Returns
-
A Result in a panic state
Creates a successful Result.
Creates a successful Result.
Type parameters
- A
-
The type of the successful value
- E
-
The type of the error (not used in this case)
Value parameters
- value
-
The successful value
Attributes
- Returns
-
A successful Result
Givens
Givens
Extensions
Extensions
Gets the exception from an Error.
Gets the exception from an Error.
Value parameters
- ev
-
Evidence that E is a subtype of Throwable
Attributes
- Returns
-
The exception
Gets the error value if present.
Gets the error value if present.
Attributes
- Returns
-
A Maybe containing the error value, or empty for non-Fail Results
Applies a predicate to the successful value of this Result.
Applies a predicate to the successful value of this Result.
Value parameters
- p
-
The predicate to apply
Attributes
- Returns
-
A new Result that fails if the predicate doesn't hold
Applies a function to the successful value of this Result.
Applies a function to the successful value of this Result.
Type parameters
- B
-
The type of the resulting successful value
- E2
-
The error type of the resulting Result
Value parameters
- f
-
The function to apply
Attributes
- Returns
-
A new Result after applying the function
Flattens a nested Result.
Flattens a nested Result.
Type parameters
- B
-
The successful type of the inner Result
- E2
-
The error type of the inner Result
Value parameters
- ev
-
Evidence that A is a Result
Attributes
- Returns
-
The flattened Result
Folds the Result into a value.
Folds the Result into a value.
Type parameters
- B
-
The type of the result of folding
Value parameters
- ifFailure
-
Function to apply if the Result is a failure
- ifSuccess
-
Function to apply if the Result is a success
Attributes
- Returns
-
The result of applying the appropriate function
Gets the successful value.
Gets the successful value.
Value parameters
- ev
-
Evidence that E is Nothing
Attributes
- Returns
-
The successful value
- Throws
-
NoSuchElementException
if the Result is a Fail
Throwableif the Result is a Panic
Gets the successful value or returns a default value.
Gets the successful value or returns a default value.
Type parameters
- B
-
A supertype of A
Value parameters
- default
-
The default value to return if the Result is not a Success
Attributes
- Returns
-
The successful value or the default value
Checks if the Result is a Fail.
Checks if the Result is a Fail.
Attributes
- Returns
-
true if the Result is a Fail, false otherwise
Checks if the Result is a Panic.
Checks if the Result is a Panic.
Attributes
- Returns
-
true if the Result is a Panic, false otherwise
Checks if the Result is a Success.
Checks if the Result is a Success.
Attributes
- Returns
-
true if the Result is a Success, false otherwise
Applies a function to the successful value of this Result.
Applies a function to the successful value of this Result.
Type parameters
- B
-
The type of the resulting successful value
Value parameters
- f
-
The function to apply
Attributes
- Returns
-
A new Result after applying the function
Applies a function to the error value of this Result.
Applies a function to the error value of this Result.
Type parameters
- E2
-
The type of the resulting error
Value parameters
- f
-
The function to apply
Attributes
- Returns
-
A new Result after applying the function to the error
Returns this Result if it's a Success, or an alternative Result if it's not.
Returns this Result if it's a Success, or an alternative Result if it's not.
Type parameters
- B
-
A supertype of A
- E2
-
The error type of the alternative Result
Value parameters
- alternative
-
The alternative Result to return if this Result is not a Success
Attributes
- Returns
-
This Result if it's a Success, or the alternative Result
Gets the panic exception if present.
Gets the panic exception if present.
Attributes
- Returns
-
A Maybe containing the panic exception, or empty for non-Panic Results
Recovers from an error by applying a partial function.
Recovers from an error by applying a partial function.
Type parameters
- B
-
A supertype of A
Value parameters
- pf
-
The partial function to apply to the error
Attributes
- Returns
-
A new Result with the error potentially recovered
Recovers from an error by applying a partial function that returns a new Result.
Recovers from an error by applying a partial function that returns a new Result.
Type parameters
- B
-
A supertype of A
- E2
-
The error type of the resulting Result
Value parameters
- pf
-
The partial function to apply to the error
Attributes
- Returns
-
A new Result with the error potentially recovered
Returns a string representation of the Result.
Returns a string representation of the Result.
Attributes
- Returns
-
A string describing the Result's state and value
Swaps the success and failure cases of the Result.
Swaps the success and failure cases of the Result.
Attributes
- Returns
-
A new Result with success and failure swapped
Converts the Result to an Either.
Converts the Result to an Either.
Attributes
- Returns
-
An Either with Left containing the error or exception, and Right containing the successful value
Converts the Result to a Maybe.
Converts the Result to a Maybe.
Attributes
- Returns
-
A Maybe containing the successful value, or empty for non-Success Results
Converts the Result to a Try.
Converts the Result to a Try.
Value parameters
- ev
-
Evidence that E is a subtype of Throwable
Attributes
- Returns
-
A Try containing the successful value, or Failure with the error
Gets the successful value if present.
Gets the successful value if present.
Attributes
- Returns
-
A Maybe containing the successful value, or empty for non-Success Results
Applies a predicate to the successful value of this Result.
Applies a predicate to the successful value of this Result.
Value parameters
- p
-
The predicate to apply
Attributes
- Returns
-
A new Result that fails if the predicate doesn't hold