CanonSharp/CanonSharp.Combinator/Extensions/ReadStateExtensions.cs

19 lines
438 B
C#
Raw Normal View History

using CanonSharp.Combinator.Abstractions;
namespace CanonSharp.Combinator.Extensions;
public static class ReadStateExtensions
{
public static IEnumerable<TState> AsEnumerable<TToken, TState>(this TState source)
where TState : IReadState<TToken, TState>
{
TState current = source;
while (current.HasValue)
{
yield return current;
current = current.Next;
}
}
}