anyreader/utils.go
2023-06-30 20:43:23 +02:00

34 lines
515 B
Go

package anyreader
func sliceToFunc[T any](s []T) func() (T, error) {
i := 0
return func() (T, error) {
c := i
if c >= len(s) {
return *new(T), ErrNoMoreValues.New()
}
i++
return s[c], nil
}
}
func findFirstTrue[T any](value T, functions []func(T) bool) bool {
for _, f := range functions {
if f(value) {
return true
}
}
return false
}
func findFirstFalse[T any](rn T, functions []func(T) bool) bool {
for _, f := range functions {
if !f(rn) {
return false
}
}
return true
}