diff options
author | nea <nea@nea.moe> | 2023-07-04 04:22:13 +0200 |
---|---|---|
committer | nea <nea@nea.moe> | 2023-07-04 04:22:13 +0200 |
commit | 4444fcca44d9a53c8162d69e0e9f19fd214c2f54 (patch) | |
tree | 3061008b93a4f994923c6523c99c754abfe3e4d1 /src/main/kotlin/moe/nea/firmament/util/assertions.kt | |
parent | d4410a67fb43cf467194b67552cdf4b85c6753bd (diff) | |
download | Firmament-4444fcca44d9a53c8162d69e0e9f19fd214c2f54.tar.gz Firmament-4444fcca44d9a53c8162d69e0e9f19fd214c2f54.tar.bz2 Firmament-4444fcca44d9a53c8162d69e0e9f19fd214c2f54.zip |
Add text rendering debugging
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/util/assertions.kt')
-rw-r--r-- | src/main/kotlin/moe/nea/firmament/util/assertions.kt | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/util/assertions.kt b/src/main/kotlin/moe/nea/firmament/util/assertions.kt new file mode 100644 index 0000000..0fe569a --- /dev/null +++ b/src/main/kotlin/moe/nea/firmament/util/assertions.kt @@ -0,0 +1,20 @@ +package moe.nea.firmament.util + +/** + * Less aggressive version of `require(obj != null)`, which fails in devenv but continues at runtime. + */ +inline fun <T : Any> assertNotNullOr(obj: T?, block: () -> T): T { + assert(obj != null) + return obj ?: block() +} + + +/** + * Less aggressive version of `require(condition)`, which fails in devenv but continues at runtime. + */ +inline fun assertTrueOr(condition: Boolean, block: () -> Unit) { + assert(condition) + if (!condition) block() +} + + |