mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-09-04 09:45:19 +08:00
Added runOrTrue, runOrFalse function in UtilsFactory
This commit is contained in:
@@ -25,6 +25,8 @@
|
|||||||
*
|
*
|
||||||
* This file is Created by fankes on 2022/2/5.
|
* This file is Created by fankes on 2022/2/5.
|
||||||
*/
|
*/
|
||||||
|
@file:Suppress("unused")
|
||||||
|
|
||||||
package com.highcapable.yukihookapi.hook.utils
|
package com.highcapable.yukihookapi.hook.utils
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream
|
import java.io.ByteArrayOutputStream
|
||||||
@@ -87,6 +89,20 @@ internal inline fun <T> T.takeIf(other: Any?, predicate: (T) -> Boolean) = if (o
|
|||||||
*/
|
*/
|
||||||
internal inline fun <T, R> T.let(other: Any?, block: (T) -> R) = if (other != null) let(block) else null
|
internal inline fun <T, R> T.let(other: Any?, block: (T) -> R) = if (other != null) let(block) else null
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 条件判断方法体捕获异常返回 true
|
||||||
|
* @param block 原始方法体
|
||||||
|
* @return [Boolean]
|
||||||
|
*/
|
||||||
|
internal inline fun runOrTrue(block: () -> Boolean) = runCatching { block() }.getOrNull() ?: true
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 条件判断方法体捕获异常返回 false
|
||||||
|
* @param block 原始方法体
|
||||||
|
* @return [Boolean]
|
||||||
|
*/
|
||||||
|
internal inline fun runOrFalse(block: () -> Boolean) = runCatching { block() }.getOrNull() ?: false
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取完整的异常堆栈内容
|
* 获取完整的异常堆栈内容
|
||||||
* @return [String]
|
* @return [String]
|
||||||
|
Reference in New Issue
Block a user