diff --git a/src/Result/Extensions/Extensions.Enumerable.cs b/src/Result/Extensions/Extensions.Enumerable.cs
index 362dc39..800122a 100644
--- a/src/Result/Extensions/Extensions.Enumerable.cs
+++ b/src/Result/Extensions/Extensions.Enumerable.cs
@@ -45,7 +45,7 @@ public static partial class Extensions
///
///
// ReSharper disable once InconsistentNaming
- public static async Task>> Join(this IEnumerable>> results)
+ public static async ValueTask>> Join(this IEnumerable>> results)
{
_ = results.TryGetNonEnumeratedCount(out var count);
var list = new List(count);
@@ -70,7 +70,7 @@ public static partial class Extensions
///
///
// ReSharper disable once InconsistentNaming
- public static async ValueTask>> Join(this IEnumerable>> results)
+ public static async Task>> Join(this IEnumerable>> results)
{
_ = results.TryGetNonEnumeratedCount(out var count);
var list = new List(count);
diff --git a/src/Result/Extensions/Extensions.Task.cs b/src/Result/Extensions/Extensions.Task.cs
index 05e530e..a015465 100644
--- a/src/Result/Extensions/Extensions.Task.cs
+++ b/src/Result/Extensions/Extensions.Task.cs
@@ -12,6 +12,36 @@ namespace Geekeey.Extensions.Result;
[ExcludeFromCodeCoverage]
public static partial class Extensions
{
+ #region ValueTask>
+
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ // ReSharper disable once InconsistentNaming
+ public static async ValueTask> Map(this ValueTask> result,
+ Func func)
+ => (await result).Map(func);
+
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static async ValueTask> MapAsync(this ValueTask> result,
+ Func> func)
+ => await (await result).MapAsync(func);
+
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ // ReSharper disable once InconsistentNaming
+ public static async ValueTask> Then(this ValueTask> result,
+ Func> func)
+ => (await result).Then(func);
+
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static async ValueTask> ThenAsync(this ValueTask> result,
+ Func>> func)
+ => await (await result).ThenAsync(func);
+
+ #endregion
+
#region Task>
///
@@ -59,34 +89,4 @@ public static partial class Extensions
=> await (await result).ThenAsync(func);
#endregion
-
- #region ValueTask>
-
- ///
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- // ReSharper disable once InconsistentNaming
- public static async ValueTask> Map(this ValueTask> result,
- Func func)
- => (await result).Map(func);
-
- ///
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static async ValueTask> MapAsync(this ValueTask> result,
- Func> func)
- => await (await result).MapAsync(func);
-
- ///
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- // ReSharper disable once InconsistentNaming
- public static async ValueTask> Then(this ValueTask> result,
- Func> func)
- => (await result).Then(func);
-
- ///
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static async ValueTask> ThenAsync(this ValueTask> result,
- Func>> func)
- => await (await result).ThenAsync(func);
-
- #endregion
}
\ No newline at end of file
diff --git a/src/Result/Result.Matching.cs b/src/Result/Result.Matching.cs
index 7fe3c3a..91f581f 100644
--- a/src/Result/Result.Matching.cs
+++ b/src/Result/Result.Matching.cs
@@ -46,8 +46,8 @@ public readonly partial struct Result
/// A task completing with the result of applying either or
/// on the success value or failure value of the result.
[Pure]
- public async ValueTask MatchAsync(Func> success, Func> failure)
- => _success ? await success(Value!) : await failure(Error!);
+ public ValueTask MatchAsync(Func> success, Func> failure)
+ => _success ? success(Value!) : failure(Error!);
///
/// Asynchronously matches over the success value or failure value of the result and invokes an effectful action
@@ -56,11 +56,8 @@ public readonly partial struct Result
///
/// The function to call with the success value of the result if the result is a success.
/// The function to call with the failure value of the result if the result is a failure.
- public async ValueTask SwitchAsync(Func success, Func failure)
- {
- if (_success) await success(Value!);
- else await failure(Error!);
- }
+ public ValueTask SwitchAsync(Func success, Func failure)
+ => _success ? success(Value!) : failure(Error!);
}
public readonly partial struct Result
@@ -86,9 +83,6 @@ public readonly partial struct Result
///
/// The function to call with the success value of the result if the result is a success.
/// The function to call with the failure value of the result if the result is a failure.
- public async Task SwitchAsync(Func success, Func failure)
- {
- if (_success) await success(Value!);
- else await failure(Error!);
- }
+ public Task SwitchAsync(Func success, Func failure)
+ => _success ? success(Value!) : failure(Error!);
}
\ No newline at end of file