Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

package net.llvg.utilities.scope

import kotlin.contracts.InvocationKind
import kotlin.contracts.contract
import kotlin.internal.InlineOnly
import net.llvg.utilities.noExcept

Expand All @@ -27,6 +29,10 @@ internal data class TryWithResourcesScopeImpl(

@InlineOnly
public inline fun <R> tryWithResources(action: TryWithResourcesScope.() -> R): R {
contract {
callsInPlace(action, InvocationKind.EXACTLY_ONCE)
}

val resources: MutableList<AutoCloseable> = ArrayList()
return try {
TryWithResourcesScopeImpl(resources).action()
Expand Down