mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2025-11-11 17:40:27 +00:00
update dependencies
This commit is contained in:
12
ksp/generator/src/main/kotlin/NoSuchElementWorkaround.kt
Normal file
12
ksp/generator/src/main/kotlin/NoSuchElementWorkaround.kt
Normal file
@@ -0,0 +1,12 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user