public static IAsyncResultEnumerable <TResult, TFailure> SelectMany <TSuccess, TFailure, TBind, TResult>(this IResultEnumerable <TSuccess, TFailure> source, Func <TSuccess, IAsyncEnumerable <TBind> > bind, Func <TSuccess, TBind, Task <TResult> > resultSelector)
        {
            if (bind == null)
            {
                throw new ArgumentNullException(nameof(bind));
            }

            if (resultSelector == null)
            {
                throw new ArgumentNullException(nameof(resultSelector));
            }

            return(source
                   .AsAsyncEnumerable()
                   .SelectMany(result => result
                               .Match(success =>
                                      bind
                                      .Invoke(success)
                                      .SelectAsync(obj => resultSelector.Invoke(success, obj))
                                      .Select(Result.Success <TResult, TFailure>),
                                      failure => AsyncEnumerable.Repeat(Result.Failure <TResult, TFailure>(failure), 1)
                                      )
                               )
                   .AsAsyncResultEnumerable());
        }
        public static IAsyncResultEnumerable <TResult, TFailure> SelectMany <TSuccess, TFailure, TBind, TResult>(this IResultEnumerable <TSuccess, TFailure> source, Func <TSuccess, Task <Result <TBind, TFailure> > > bind, Func <TSuccess, TBind, Task <TResult> > resultSelector)
            where TSuccess : notnull
            where TFailure : notnull
            where TBind : notnull
            where TResult : notnull
        {
            if (bind == null)
            {
                throw new ArgumentNullException(nameof(bind));
            }

            if (resultSelector == null)
            {
                throw new ArgumentNullException(nameof(resultSelector));
            }

            return(source
                   .AsAsyncEnumerable()
                   .SelectAsync(result => result
                                .MatchAsync(success =>
                                            bind
                                            .Invoke(success)
                                            .MapAsync(value => resultSelector.Invoke(success, value)),
                                            failure => Task.FromResult(Result.Failure <TResult, TFailure>(failure))
                                            )
                                )
                   .AsAsyncResultEnumerable());
        }