upmigration

This commit is contained in:
2020-12-02 14:39:54 +06:00
parent 7bc1e822fc
commit f27c493771
29 changed files with 94 additions and 87 deletions

View File

@@ -0,0 +1,21 @@
package dev.inmo.saucenaoapi.utils
import kotlinx.coroutines.supervisorScope
interface SauceCloseable {
fun close()
}
fun <T> SauceCloseable.use(block: (SauceCloseable) -> T): T = try {
block(this)
} finally {
close()
}
suspend fun <T> SauceCloseable.useSafe(block: suspend (SauceCloseable) -> T): T = try {
supervisorScope {
block(this@useSafe)
}
} finally {
close()
}