github.com/haraldrudell/parl@v0.4.176/iters/empty.go (about)

     1  /*
     2  © 2022–present Harald Rudell <harald.rudell@gmail.com> (https://haraldrudell.github.io/haraldrudell/)
     3  ISC License
     4  */
     5  
     6  package iters
     7  
     8  // Empty is an iterator with no values. thread-safe.
     9  type Empty[T any] struct{}
    10  
    11  // NewEmptyIterator returns an empty iterator of values type T.
    12  //   - EmptyIterator is thread-safe.
    13  func NewEmptyIterator[T any]() (iterator Iterator[T]) { return &Empty[T]{} }
    14  func (i *Empty[T]) Init() (iterationVariable T, iterator Iterator[T]) {
    15  	iterator = i
    16  	return
    17  }
    18  func (i *Empty[T]) Cond(iterationVariablep *T, errp ...*error) (condition bool) { return }
    19  func (i *Empty[T]) Next() (value T, hasValue bool)                              { return }
    20  func (i *Empty[T]) Same() (value T, hasValue bool)                              { return }
    21  func (i *Empty[T]) Cancel(errp ...*error) (err error)                           { return }