Enum Result

enum Result[A, B] {
    Failure(A),
    Success(B)
}

Result is an enum that holds either a Failure or Success. This enum is for situations where the function that fails has an error message to deliver. Examples of that include a database query or a more humble rpn calculator.

Methods

define failure: Option[A]

If self contains a Failure, produces a Some(A).

If self contains a Right, produces None.

define is_failure: Boolean

Return true if self contains a Failure, false otherwise.

define is_success: Boolean

Return true if self contains a Success, false otherwise.

define success: Option[B]

If self contains a Failure, produces a None.

If self contains a Success, produces Right(B).