-
Notifications
You must be signed in to change notification settings - Fork 4
/
EnumeratorEx.cs
25 lines (24 loc) · 977 Bytes
/
EnumeratorEx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
using System;
using System.Collections.Generic;
namespace Gapotchenko.FX.Linq
{
/// <summary>
/// Provides an extended set of static methods for querying objects that implement <see cref="IEnumerator{T}"/>.
/// </summary>
public static class EnumeratorEx
{
/// <summary>
/// Returns the enumeration of remaining elements for the given enumerator.
/// </summary>
/// <typeparam name="T">The type of elements in enumerator.</typeparam>
/// <param name="enumerator">The enumerator.</param>
/// <returns>An <see cref="IEnumerable{T}"/> that contains the remaining elements of the given enumerator.</returns>
public static IEnumerable<T> Rest<T>(this IEnumerator<T> enumerator)
{
if (enumerator == null)
throw new ArgumentNullException(nameof(enumerator));
while (enumerator.MoveNext())
yield return enumerator.Current;
}
}
}