get back either serializer fun

This commit is contained in:
InsanusMokrassar 2022-04-07 09:59:58 +06:00
parent bc37b11cee
commit 4790fe0aea

View File

@ -27,6 +27,13 @@ sealed interface Either<T1, T2> {
@Deprecated("Use optionalT2 instead", ReplaceWith("optionalT2")) @Deprecated("Use optionalT2 instead", ReplaceWith("optionalT2"))
val t2: T2? val t2: T2?
get() = optionalT2.dataOrNull() get() = optionalT2.dataOrNull()
companion object {
fun <T1, T2> serializer(
t1Serializer: KSerializer<T1>,
t2Serializer: KSerializer<T2>,
): KSerializer<Either<T1, T2>> = EitherSerializer(t1Serializer, t2Serializer)
}
} }
class EitherSerializer<T1, T2>( class EitherSerializer<T1, T2>(