/// <summary> /// Returns a <see cref="IEither{T,TError}" /> when awaited. /// </summary> /// <param name="source"> /// The <see cref="IAsyncEither{T,TError}" />. /// </param> /// <typeparam name="T"> /// of <see cref="IAsyncEither{T,TError}" />. /// The <typeparamref name="T" /> /// </typeparam> /// <typeparam name="TError"> /// The <typeparamref name="TError" /> of <see cref="IAsyncEither{T,TError}" />. /// </typeparam> /// <returns></returns> public static TaskAwaiter <IEither <T, TError> > GetAwaiter <T, TError>(this IAsyncEither <T, TError> source) => source?.ToTaskEither().GetAwaiter() ?? throw new ArgumentNullException(nameof(source));
internal static async Task <IEither <T, TError> > ToTaskEither <T, TError>(this IAsyncEither <T, TError> asyncEither) => await asyncEither.HasValue.ConfigureAwait(false) ? Result.Value <T, TError>(asyncEither.Value).Either : Result.Error <T, TError>(asyncEither.Error).Either;