feat: update mustget behavior

This commit is contained in:
2026-02-11 19:24:48 -05:00
parent 654c38cc9c
commit a230ff9bc7

View File

@@ -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. // MustGet is a version of Get, that panics if the datum cannot be returned.
func (i Iterator[T]) MustGet() T { func (i Iterator[T]) MustGet() T {
var null T t, err := i.Get()
if i.Done() { if err != nil {
return null 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 // Forward increments the iterator if the iterator is not yet at the end of the