19 lines
438 B
C#
19 lines
438 B
C#
|
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;
|
||
|
}
|
||
|
}
|
||
|
}
|