Files
MicroUtils/ksp/generator/src/main/kotlin/NoSuchElementWorkaround.kt
2025-11-05 13:42:27 +06:00

13 lines
249 B
Kotlin

package dev.inmo.micro_ksp.generator
inline fun <T> withNoSuchElementWorkaround(
default: T,
block: () -> T
): T = runCatching(block).getOrElse {
if (it is NoSuchElementException) {
default
} else {
throw it
}
}