diff --git a/result4k/kotest/src/main/kotlin/dev/forkhandles/result4k/kotest/matchers.kt b/result4k/kotest/src/main/kotlin/dev/forkhandles/result4k/kotest/matchers.kt index 92cd69f..63fe16a 100644 --- a/result4k/kotest/src/main/kotlin/dev/forkhandles/result4k/kotest/matchers.kt +++ b/result4k/kotest/src/main/kotlin/dev/forkhandles/result4k/kotest/matchers.kt @@ -19,16 +19,16 @@ fun beSuccess(): Matcher> = object : Matcher> { } @OptIn(ExperimentalContracts::class) -fun Result.shouldBeSuccess() { +fun Result.shouldBeSuccess(): T { contract { - returns() implies (this@shouldBeSuccess is Success<*>) + returns() implies (this@shouldBeSuccess is Success) } this should beSuccess() + return (this as Success).value } infix fun Result.shouldBeSuccess(block: (T) -> Unit) { - this.shouldBeSuccess() - block((this as Success).value) + block(this.shouldBeSuccess()) } infix fun Result.shouldBeSuccess(value: T) = this should beSuccess(value)