Hi community,
The type of yield occurs twice in the function declaration and
at the return statement.
```
func (s *Set[E]) All() iter.Seq[E] {
return func(yield func(E) bool) {
for v := range s.m {
if !yield(v) {
return
}
}
}
}
```
How about add yield types like this?
I think it can simplify the code a bit.
```
type Yield[V any] func(V) bool
type Yield2[K, V any] func(K, V) bool
func sliceDemo[K int, V any](s []V) func(Yield2[K, V]) {
return func(yield Yield2[K, V]) {
for i, v := range s {
if !yield(K(i), v) {
break
}
}
}
}
func mapDemo[K comparable, V any](s map[K]V) func(Yield2[K, V]) {
return func(yield Yield2[K, V]) {
for i, v := range s {
if !yield(i, v) {
break
}
}
}
}
```