mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-07-26 06:38:42 +00:00
runtime: implement newcoro, coroswitch to support package iter
This commit is contained in:
Vendored
+18
-3
@@ -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) {
|
||||
|
||||
Vendored
+10
@@ -8,4 +8,14 @@
|
||||
3
|
||||
2
|
||||
1
|
||||
10
|
||||
9
|
||||
8
|
||||
7
|
||||
6
|
||||
5
|
||||
4
|
||||
3
|
||||
2
|
||||
1
|
||||
go1.23 has lift-off!
|
||||
|
||||
Reference in New Issue
Block a user