mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2026-01-19 11:48:02 +00:00
13 lines
249 B
Kotlin
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
|
|
}
|
|
}
|