Skip to content

Commit

Permalink
Finally(): superfluous async/await removed in static class AsyncResul…
Browse files Browse the repository at this point in the history
…tExtensionsRightOperand.
  • Loading branch information
mnissl committed Feb 24, 2022
1 parent a60da7b commit dd764c5
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions CSharpFunctionalExtensions/Result/Extensions/FinallyAsyncRight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,25 @@ public static partial class AsyncResultExtensionsRightOperand
/// <summary>
/// Passes the result to the given function (regardless of success/failure state) to yield a final output value.
/// </summary>
public static async Task<T> Finally<T>(this Result result, Func<Result, Task<T>> func)
{
return await func(result).DefaultAwait();
}
public static Task<T> Finally<T>(this Result result, Func<Result, Task<T>> func)
=> func(result);

/// <summary>
/// Passes the result to the given function (regardless of success/failure state) to yield a final output value.
/// </summary>
public static async Task<K> Finally<T, K>(this Result<T> result, Func<Result<T>, Task<K>> func)
{
return await func(result).DefaultAwait();
}
public static Task<K> Finally<T, K>(this Result<T> result, Func<Result<T>, Task<K>> func)
=> func(result);

/// <summary>
/// Passes the result to the given function (regardless of success/failure state) to yield a final output value.
/// </summary>
public static async Task<K> Finally<K, E>(this UnitResult<E> result, Func<UnitResult<E>, Task<K>> func)
{
return await func(result).DefaultAwait();
}
public static Task<K> Finally<K, E>(this UnitResult<E> result, Func<UnitResult<E>, Task<K>> func)
=> func(result);

/// <summary>
/// Passes the result to the given function (regardless of success/failure state) to yield a final output value.
/// </summary>
public static async Task<K> Finally<T, K, E>(this Result<T, E> result, Func<Result<T, E>, Task<K>> func)
{
return await func(result).DefaultAwait();
}
public static Task<K> Finally<T, K, E>(this Result<T, E> result, Func<Result<T, E>, Task<K>> func)
=> func(result);
}
}

0 comments on commit dd764c5

Please sign in to comment.