// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; namespace System.Linq { public static partial class AsyncEnumerable { public static IAsyncEnumerable Empty() { return new EmptyAsyncIterator(); } private sealed class EmptyAsyncIterator : AsyncIterator, IAsyncIListProvider { public override AsyncIterator Clone() => new EmptyAsyncIterator(); public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) => Task.FromResult(0); public Task ToArrayAsync(CancellationToken cancellationToken) => Task.FromResult(Array.Empty()); public Task> ToListAsync(CancellationToken cancellationToken) => Task.FromResult(new List()); protected override Task MoveNextCore() => TaskExt.False; } } }