/// <summary> /// Consume the source async sequence by emitting items and terminal signals via /// the given <see cref="IAsyncConsumer{T}" /> consumer. /// </summary> /// <typeparam name="TSource">The element type.</typeparam> /// <param name="source">The source sequence to consume.</param> /// <param name="consumer">The push-awaitable consumer.</param> /// <param name="ct">The optional cancellation token to stop the consumption.</param> /// <returns>The task that is completed when the consumption terminates.</returns> public static ValueTask Consume <TSource>(this IAsyncEnumerable <TSource> source, IAsyncConsumer <TSource> consumer, CancellationToken ct = default) { RequireNonNull(source, nameof(source)); RequireNonNull(consumer, nameof(consumer)); return(ForEach.Consume(source, consumer, ct)); }