Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 00bdb89b authored by Sebastiano Barezzi's avatar Sebastiano Barezzi
Browse files

Twelve: Result: Mark mapping methods as inline

So that we can run suspend stuff if needed

Change-Id: I9c81023acf8c867069f1b36aca3e81384c643d74
parent be3f4495
Loading
Loading
Loading
Loading
+4 −4
Original line number Original line Diff line number Diff line
@@ -35,7 +35,7 @@ sealed class Result<T, E> {
        /**
        /**
         * Map the result to another type.
         * Map the result to another type.
         */
         */
        fun <T, E, R> Result<T, E>.map(
        inline fun <T, E, R> Result<T, E>.map(
            mapping: (T) -> R
            mapping: (T) -> R
        ): Result<R, E> = when (this) {
        ): Result<R, E> = when (this) {
            is Success -> Success(mapping(data))
            is Success -> Success(mapping(data))
@@ -46,14 +46,14 @@ sealed class Result<T, E> {
         * Map the result to another type.
         * Map the result to another type.
         */
         */
        @JvmName("mapNullable")
        @JvmName("mapNullable")
        fun <T, E, R> Result<T, E>?.map(
        inline fun <T, E, R> Result<T, E>?.map(
            mapping: (T) -> R
            mapping: (T) -> R
        ): Result<R, E>? = this?.map(mapping)
        ): Result<R, E>? = this?.map(mapping)


        /**
        /**
         * Fold the request status.
         * Fold the request status.
         */
         */
        fun <T, E, R> Result<T, E>.fold(
        inline fun <T, E, R> Result<T, E>.fold(
            onSuccess: (T) -> R,
            onSuccess: (T) -> R,
            onError: (E) -> R,
            onError: (E) -> R,
        ): R = when (this) {
        ): R = when (this) {
@@ -64,7 +64,7 @@ sealed class Result<T, E> {
        /**
        /**
         * Fold the request status.
         * Fold the request status.
         */
         */
        fun <T, E, R> Result<T, E>?.fold(
        inline fun <T, E, R> Result<T, E>?.fold(
            onNull: () -> R,
            onNull: () -> R,
            onSuccess: (T) -> R,
            onSuccess: (T) -> R,
            onError: (E) -> R,
            onError: (E) -> R,