toOptional

Transforms a KResult to a Java Optional

Head up: We're loosing type information of the Failure side when transforming a KResult to an Optional, so this operation is irreversible.

import io.kresult.core.KResult
import io.kresult.java.toOptional
import io.kotest.matchers.shouldBe

fun test() {
KResult.Success("test")
.toOptional()
.isPresent shouldBe true
}