10 lines
332 B
Kotlin
Vendored
10 lines
332 B
Kotlin
Vendored
import kotlin.contracts.*
|
|
|
|
fun calculateNumber(block: () -> Int): Int contract [
|
|
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
|
] = block()
|
|
|
|
fun <R> calculateResult(num: Int?, calculate: (Int?) -> R): R contract [
|
|
callsInPlace(calculate, InvocationKind.EXACTLY_ONCE),
|
|
returns() implies (num != null)
|
|
] = calculate(num) |