Commit 7e55c6f3 authored by Him188's avatar Him188

Simplify code

parent df3838b9
......@@ -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].
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment