cast<U, F> method

Result<U, F> cast<U, F>()

Returns a Result<U, F> where value/error is cast to the corresponding type.

If casting fails, throws a TypeError.

Implementation

Result<U, F> cast<U, F>() =>
    isOk ? Result<U, F>.ok(_value as U) : Result<U, F>.err(_error as F);