mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-09 09:50:16 +08:00
Simplify code
This commit is contained in:
parent
df3838b924
commit
7e55c6f342
@ -90,10 +90,7 @@ inline fun LoginResult.requireSuccess(lazyMessage: (LoginResult) -> String) {
|
||||
* 检查 [this] 为 [LoginResult.SUCCESS].
|
||||
* 失败则 [error]
|
||||
*/
|
||||
fun LoginResult.requireSuccess() {
|
||||
if (requireSuccessOrNull() === null)
|
||||
error("Login failed: $this")
|
||||
}
|
||||
fun LoginResult.requireSuccess() = requireSuccess { "Login failed: $this" }
|
||||
|
||||
/**
|
||||
* 检查 [this] 为 [LoginResult.SUCCESS].
|
||||
@ -101,10 +98,7 @@ fun LoginResult.requireSuccess() {
|
||||
*
|
||||
* @return 成功时 [Unit], 失败时 `null`
|
||||
*/
|
||||
fun LoginResult.requireSuccessOrNull(): Unit? {
|
||||
return if (this == SUCCESS) Unit else null
|
||||
}
|
||||
|
||||
fun LoginResult.requireSuccessOrNull(): Unit? = if (this == SUCCESS) Unit else null
|
||||
|
||||
/**
|
||||
* 检查 [this] 为 [LoginResult.SUCCESS].
|
||||
|
Loading…
Reference in New Issue
Block a user