Hi… I am well aware that this diff view is very suboptimal. It will be fixed when the refactored server comes along!
misc: Move IterSeqLimit to misc
// SPDX-License-Identifier: AGPL-3.0-only // SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org>
package forge
package misc
import "iter" // iterSeqLimit returns an iterator equivalent to the supplied one, but stops // after n iterations.
func iterSeqLimit[T any](s iter.Seq[T], n uint) iter.Seq[T] {
func IterSeqLimit[T any](s iter.Seq[T], n uint) iter.Seq[T] {
return func(yield func(T) bool) {
var iterations uint
for v := range s {
if iterations > n-1 {
return
}
if !yield(v) {
return
}
iterations++
}
}
}