runtime: implement newcoro, coroswitch to support package iter

This commit is contained in:
Elias Naur
2024-10-06 17:47:48 +02:00
committed by Ayke
parent d5f195387d
commit 07d23c9d83
3 changed files with 59 additions and 3 deletions
+18 -3
View File
@@ -1,14 +1,29 @@
package main
import "iter"
func main() {
testFuncRange(counter)
testIterPull(counter)
println("go1.23 has lift-off!")
}
func testFuncRange(f func(yield func(int) bool)) {
for i := range f {
func testFuncRange(it iter.Seq[int]) {
for i := range it {
println(i)
}
}
func testIterPull(it iter.Seq[int]) {
next, stop := iter.Pull(it)
defer stop()
for {
i, ok := next()
if !ok {
break
}
println(i)
}
println("go1.23 has lift-off!")
}
func counter(yield func(int) bool) {
+10
View File
@@ -8,4 +8,14 @@
3
2
1
10
9
8
7
6
5
4
3
2
1
go1.23 has lift-off!