Example #1
0
 public Option <IImmutableEnumeratorElement <U> > MoveNext()
 {
     if (this.last.EXPLICITLY_DISPOSED)
     {
         throw new ObjectDisposedException("Cannot use an ImmutableEnumerator after it was explicitly disposed.");
     }
     return(next.NEXT.Match(
                AlreadyUnfoldedEnd: () =>
                Option.None <IImmutableEnumeratorElement <U> >(),
                AlreadyUnfolded: element =>
                element.Some(),
                NotUnfoldedYet: (e, last) => {
         if (e.MoveNext())
         {
             var lst = new LazyList {
                 NEXT = new State.NotUnfoldedYet(e, last)
             };
             last.LAST = lst;
             var elem = new ImmutableEnumeratorElement(
                 current: e.Current,
                 next: lst,
                 last: last);
             next.NEXT = new State.AlreadyUnfolded(elem);
             return elem.Some();
         }
         else
         {
             next.NEXT = new State.AlreadyUnfoldedEnd();
             // Call .Dispose() on the underlying enumerator
             // because we have read all its elements.
             e.Dispose();
             return Option.None <IImmutableEnumeratorElement <U> >();
         }
     }
                ));
 }
Example #2
0
File: State.cs Project: envlang/env
 public AlreadyUnfolded(ImmutableEnumeratorElement value)
 {
     this.value = value;
 }