diff --git a/src/main/kotlin/com/github/michaelbull/result/Binding.kt b/src/main/kotlin/com/github/michaelbull/result/Binding.kt index 5a8a3f4..0da30c5 100644 --- a/src/main/kotlin/com/github/michaelbull/result/Binding.kt +++ b/src/main/kotlin/com/github/michaelbull/result/Binding.kt @@ -1,5 +1,8 @@ package com.github.michaelbull.result +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract + /** * Calls the specified function [block] with [ResultBinding] as its receiver and returns its [Result]. * @@ -22,6 +25,10 @@ package com.github.michaelbull.result * @sample com.github.michaelbull.result.bind.ResultBindingTest */ inline fun binding(crossinline block: ResultBinding.() -> V): Result { + contract { + callsInPlace(block, InvocationKind.EXACTLY_ONCE) + } + val receiver = ResultBindingImpl() return try {