diff --git a/pkg/iterator/iterator.go b/pkg/iterator/iterator.go index d7504d8..6fd1241 100644 --- a/pkg/iterator/iterator.go +++ b/pkg/iterator/iterator.go @@ -43,12 +43,12 @@ func (i Iterator[T]) Get() (T, error) { // MustGet is a version of Get, that panics if the datum cannot be returned. func (i Iterator[T]) MustGet() T { - var null T - if i.Done() { - return null + t, err := i.Get() + if err != nil { + panic(fmt.Errorf("cannot get current token: %w", err)) } - return i.items[i.index] + return t } // Forward increments the iterator if the iterator is not yet at the end of the