mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-25 15:40:28 +08:00
Add docs
This commit is contained in:
parent
fa43f2689c
commit
4c30e3d9d7
@ -12,6 +12,9 @@ import net.mamoe.mirai.console.util.cast
|
||||
import net.mamoe.mirai.console.util.safeCast
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* Builtin implementation of [CommandCallResolver]
|
||||
*/
|
||||
@ConsoleExperimentalApi
|
||||
@ExperimentalCommandDescriptors
|
||||
public object BuiltInCommandCallResolver : CommandCallResolver {
|
||||
|
@ -11,9 +11,13 @@ package net.mamoe.mirai.console.command.resolve
|
||||
|
||||
import net.mamoe.mirai.console.command.descriptor.ExperimentalCommandDescriptors
|
||||
import net.mamoe.mirai.console.command.parse.CommandCall
|
||||
import net.mamoe.mirai.console.extensions.CommandCallResolverProvider
|
||||
|
||||
/**
|
||||
* The resolver converting a [CommandCall] into [ResolvedCommandCall] based on registered []
|
||||
*
|
||||
* @see CommandCallResolverProvider The provider to instances of this class
|
||||
* @see BuiltInCommandCallResolver The builtin implementation
|
||||
*/
|
||||
@ExperimentalCommandDescriptors
|
||||
public interface CommandCallResolver {
|
||||
|
@ -11,6 +11,10 @@ package net.mamoe.mirai.console.util
|
||||
|
||||
import kotlin.contracts.contract
|
||||
|
||||
/**
|
||||
* Perform `this as? T`.
|
||||
*/
|
||||
@JvmSynthetic
|
||||
public inline fun <reified T : Any> Any?.safeCast(): T? {
|
||||
contract {
|
||||
returnsNotNull() implies (this@safeCast is T)
|
||||
@ -18,6 +22,10 @@ public inline fun <reified T : Any> Any?.safeCast(): T? {
|
||||
return this as? T
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform `this as T`.
|
||||
*/
|
||||
@JvmSynthetic
|
||||
public inline fun <reified T : Any> Any?.cast(): T {
|
||||
contract {
|
||||
returns() implies (this@cast is T)
|
||||
|
Loading…
Reference in New Issue
Block a user