feat: update mustget behavior
This commit is contained in:
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user