diff options
author | Runxi Yu <me@runxiyu.org> | 2025-04-05 23:22:51 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-04-05 23:22:51 +0800 |
commit | 38b24afcb653da88765c99049f850c3ec7e234db (patch) | |
tree | 9fa48eab9bd4ddff5323571b5746a72371628996 /iter.go | |
parent | Remove unused types/functions (diff) | |
download | forge-38b24afcb653da88765c99049f850c3ec7e234db.tar.gz forge-38b24afcb653da88765c99049f850c3ec7e234db.tar.zst forge-38b24afcb653da88765c99049f850c3ec7e234db.zip |
misc: Move IterSeqLimit to misc
Diffstat (limited to 'iter.go')
-rw-r--r-- | iter.go | 23 |
1 files changed, 0 insertions, 23 deletions
diff --git a/iter.go b/iter.go deleted file mode 100644 index e237118..0000000 --- a/iter.go +++ /dev/null @@ -1,23 +0,0 @@ -// SPDX-License-Identifier: AGPL-3.0-only -// SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org> - -package forge - -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] { - return func(yield func(T) bool) { - var iterations uint - for v := range s { - if iterations > n-1 { - return - } - if !yield(v) { - return - } - iterations++ - } - } -} |