From 631f81d8ae6d2c42069a0f6ee8453cd707f0cf76 Mon Sep 17 00:00:00 2001 From: Michael Bull Date: Fri, 19 Jan 2018 14:21:18 +0000 Subject: [PATCH] Fix mis-ordered modifier keywords https://kotlinlang.org/docs/reference/coding-conventions.html#modifiers --- src/main/kotlin/com/github/michaelbull/result/And.kt | 4 ++-- src/main/kotlin/com/github/michaelbull/result/Get.kt | 8 ++++---- src/main/kotlin/com/github/michaelbull/result/Map.kt | 6 +++--- src/main/kotlin/com/github/michaelbull/result/On.kt | 4 ++-- src/main/kotlin/com/github/michaelbull/result/Or.kt | 4 ++-- src/main/kotlin/com/github/michaelbull/result/Unwrap.kt | 4 ++-- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/main/kotlin/com/github/michaelbull/result/And.kt b/src/main/kotlin/com/github/michaelbull/result/And.kt index 518d4d7..6fc62bb 100644 --- a/src/main/kotlin/com/github/michaelbull/result/And.kt +++ b/src/main/kotlin/com/github/michaelbull/result/And.kt @@ -10,7 +10,7 @@ infix fun Result.and(result: Result): Result { * * - Rust: [Result.and](https://doc.rust-lang.org/std/result/enum.Result.html#method.and) */ -infix inline fun Result.and(result: () -> Result): Result { +inline infix fun Result.and(result: () -> Result): Result { return when (this) { is Ok -> result() is Err -> this @@ -24,7 +24,7 @@ infix inline fun Result.and(result: () -> Result): Result Result.andThen(transform: (V) -> Result): Result { +inline infix fun Result.andThen(transform: (V) -> Result): Result { return when (this) { is Ok -> transform(value) is Err -> this diff --git a/src/main/kotlin/com/github/michaelbull/result/Get.kt b/src/main/kotlin/com/github/michaelbull/result/Get.kt index 5c9c118..111bed2 100644 --- a/src/main/kotlin/com/github/michaelbull/result/Get.kt +++ b/src/main/kotlin/com/github/michaelbull/result/Get.kt @@ -40,7 +40,7 @@ infix fun Result.getOr(default: V): V { * @param default The value to return if [Err]. * @return The [value][Ok.value] if [Ok], otherwise [default]. */ -infix inline fun Result.getOr(default: () -> V): V { +inline infix fun Result.getOr(default: () -> V): V { return when (this) { is Ok -> value is Err -> default() @@ -60,7 +60,7 @@ infix fun Result.getErrorOr(default: E): E { * @param default The error to return if [Ok]. * @return The [error][Err.error] if [Err], otherwise [default]. */ -infix inline fun Result.getErrorOr(default: () -> E): E { +inline infix fun Result.getErrorOr(default: () -> E): E { return when (this) { is Ok -> default() is Err -> error @@ -74,7 +74,7 @@ infix inline fun Result.getErrorOr(default: () -> E): E { * - Elm: [Result.extract](http://package.elm-lang.org/packages/circuithub/elm-result-extra/1.4.0/Result-Extra#extract) * - Rust: [Result.unwrap_or_else](https://doc.rust-lang.org/src/core/result.rs.html#735-740) */ -infix inline fun Result.getOrElse(transform: (E) -> V): V { +inline infix fun Result.getOrElse(transform: (E) -> V): V { return when (this) { is Ok -> value is Err -> transform(error) @@ -85,7 +85,7 @@ infix inline fun Result.getOrElse(transform: (E) -> V): V { * Returns the [error][Err.error] if this [Result] is [Err], otherwise * the [transformation][transform] of the [value][Ok.value]. */ -infix inline fun Result.getErrorOrElse(transform: (V) -> E): E { +inline infix fun Result.getErrorOrElse(transform: (V) -> E): E { return when (this) { is Ok -> transform(value) is Err -> error diff --git a/src/main/kotlin/com/github/michaelbull/result/Map.kt b/src/main/kotlin/com/github/michaelbull/result/Map.kt index b51e64b..39c3a14 100644 --- a/src/main/kotlin/com/github/michaelbull/result/Map.kt +++ b/src/main/kotlin/com/github/michaelbull/result/Map.kt @@ -8,7 +8,7 @@ package com.github.michaelbull.result * - Haskell: [Data.Bifunctor.first](https://hackage.haskell.org/package/base-4.10.0.0/docs/Data-Bifunctor.html#v:first) * - Rust: [Result.map](https://doc.rust-lang.org/std/result/enum.Result.html#method.map) */ -infix inline fun Result.map(transform: (V) -> U): Result { +inline infix fun Result.map(transform: (V) -> U): Result { return when (this) { is Ok -> Ok(transform(value)) is Err -> this @@ -23,7 +23,7 @@ infix inline fun Result.map(transform: (V) -> U): Result { * - Haskell: [Data.Bifunctor.right](https://hackage.haskell.org/package/base-4.10.0.0/docs/Data-Bifunctor.html#v:second) * - Rust: [Result.map_err](https://doc.rust-lang.org/std/result/enum.Result.html#method.map_err) */ -infix inline fun Result.mapError(transform: (E) -> F): Result { +inline infix fun Result.mapError(transform: (E) -> F): Result { return when (this) { is Ok -> this is Err -> Err(transform(error)) @@ -73,6 +73,6 @@ inline fun Result.mapEither( * * - Scala: [Either.flatMap](http://www.scala-lang.org/api/2.12.0/scala/util/Either.html#flatMap[AA>:A,Y](f:B=>scala.util.Either[AA,Y]):scala.util.Either[AA,Y]) */ -infix inline fun Result.flatMap(transform: (V) -> Result): Result { +inline infix fun Result.flatMap(transform: (V) -> Result): Result { return andThen(transform) } diff --git a/src/main/kotlin/com/github/michaelbull/result/On.kt b/src/main/kotlin/com/github/michaelbull/result/On.kt index c0577b1..6826a0f 100644 --- a/src/main/kotlin/com/github/michaelbull/result/On.kt +++ b/src/main/kotlin/com/github/michaelbull/result/On.kt @@ -3,9 +3,9 @@ package com.github.michaelbull.result /** * Invokes a [callback] if this [Result] is [Ok]. */ -infix inline fun Result.onSuccess(callback: (V) -> Unit) = mapBoth(callback, {}) +inline infix fun Result.onSuccess(callback: (V) -> Unit) = mapBoth(callback, {}) /** * Invokes a [callback] if this [Result] is [Err]. */ -infix inline fun Result.onFailure(callback: (E) -> Unit) = mapBoth({}, callback) +inline infix fun Result.onFailure(callback: (E) -> Unit) = mapBoth({}, callback) diff --git a/src/main/kotlin/com/github/michaelbull/result/Or.kt b/src/main/kotlin/com/github/michaelbull/result/Or.kt index 6c7c17a..19c3397 100644 --- a/src/main/kotlin/com/github/michaelbull/result/Or.kt +++ b/src/main/kotlin/com/github/michaelbull/result/Or.kt @@ -10,7 +10,7 @@ infix fun Result.or(result: Result): Result { * * - Rust: [Result.or](https://doc.rust-lang.org/std/result/enum.Result.html#method.or) */ -infix inline fun Result.or(result: () -> Result): Result { +inline infix fun Result.or(result: () -> Result): Result { return when (this) { is Ok -> this is Err -> result() @@ -23,7 +23,7 @@ infix inline fun Result.or(result: () -> Result): Result Result.orElse(transform: (E) -> Result): Result { +inline infix fun Result.orElse(transform: (E) -> Result): Result { return when (this) { is Ok -> this is Err -> transform(error) diff --git a/src/main/kotlin/com/github/michaelbull/result/Unwrap.kt b/src/main/kotlin/com/github/michaelbull/result/Unwrap.kt index 2e94ac1..050b18a 100644 --- a/src/main/kotlin/com/github/michaelbull/result/Unwrap.kt +++ b/src/main/kotlin/com/github/michaelbull/result/Unwrap.kt @@ -29,7 +29,7 @@ infix fun Result.expect(message: String): V { * @param message The message to include in the [UnwrapException] if the [Result] is an [Err]. * @throws UnwrapException if the [Result] is an [Err], with the specified [message]. */ -infix inline fun Result.expect(message: () -> Any): V { +inline infix fun Result.expect(message: () -> Any): V { return when (this) { is Ok -> value is Err -> throw UnwrapException("${message()} $error") @@ -63,7 +63,7 @@ infix fun Result.expectError(message: String): E { * @param message The message to include in the [UnwrapException] if the [Result] is [Ok]. * @throws UnwrapException if the [Result] is [Ok], with the specified [message]. */ -infix inline fun Result.expectError(message: () -> Any): E { +inline infix fun Result.expectError(message: () -> Any): E { return when (this) { is Ok -> throw UnwrapException("${message()} $value") is Err -> error