v0.0.559 Add .Iterate and .IterateFunc methods to wmo
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Failing after 1m33s
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Failing after 1m33s
This commit is contained in:
21
langext/iter.go
Normal file
21
langext/iter.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package langext
|
||||
|
||||
import (
|
||||
"iter"
|
||||
)
|
||||
|
||||
func IterSingleValueSeq[T any](value T) iter.Seq[T] {
|
||||
return func(yield func(T) bool) {
|
||||
if !yield(value) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func IterSingleValueSeq2[T1 any, T2 any](v1 T1, v2 T2) iter.Seq2[T1, T2] {
|
||||
return func(yield func(T1, T2) bool) {
|
||||
if !yield(v1, v2) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user