mirror of https://github.com/golang/go.git
iter: expose fundamental types to Go 1.23
These were previously only available with GOEXPERIMENT=rangefunc. For #61897. Change-Id: I86aea5ae8be1f7a2975b623325811221ed40d384 Reviewed-on: https://go-review.googlesource.com/c/go/+/557836 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
parent
5122a6796e
commit
5a181c5042
|
|
@ -0,0 +1,4 @@
|
||||||
|
pkg iter, func Pull2[$0 interface{}, $1 interface{}](Seq2[$0, $1]) (func() ($0, $1, bool), func()) #61897
|
||||||
|
pkg iter, func Pull[$0 interface{}](Seq[$0]) (func() ($0, bool), func()) #61897
|
||||||
|
pkg iter, type Seq2[$0 interface{}, $1 interface{}] func(func($0, $1) bool) #61897
|
||||||
|
pkg iter, type Seq[$0 interface{}] func(func($0) bool) #61897
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
### Iterators
|
||||||
|
|
||||||
|
The new [`iter` package](/pkg/iter/) provides the basic definitions for
|
||||||
|
working with user-defined iterators.
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
<!-- see ../../3-iter.md -->
|
||||||
|
|
@ -85,11 +85,9 @@ var depsRules = `
|
||||||
< internal/reflectlite
|
< internal/reflectlite
|
||||||
< errors
|
< errors
|
||||||
< internal/oserror, math/bits
|
< internal/oserror, math/bits
|
||||||
|
< iter
|
||||||
< RUNTIME;
|
< RUNTIME;
|
||||||
|
|
||||||
internal/race
|
|
||||||
< iter;
|
|
||||||
|
|
||||||
# slices depends on unsafe for overlapping check, cmp for comparison
|
# slices depends on unsafe for overlapping check, cmp for comparison
|
||||||
# semantics, and math/bits for # calculating bitlength of numbers.
|
# semantics, and math/bits for # calculating bitlength of numbers.
|
||||||
unsafe, cmp, math/bits
|
unsafe, cmp, math/bits
|
||||||
|
|
@ -389,7 +387,6 @@ var depsRules = `
|
||||||
internal/nettrace,
|
internal/nettrace,
|
||||||
internal/poll,
|
internal/poll,
|
||||||
internal/singleflight,
|
internal/singleflight,
|
||||||
internal/race,
|
|
||||||
net/netip,
|
net/netip,
|
||||||
os
|
os
|
||||||
< net;
|
< net;
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ var stdPkgs = []string{
|
||||||
"html",
|
"html",
|
||||||
"image",
|
"image",
|
||||||
"io",
|
"io",
|
||||||
|
"iter",
|
||||||
"log",
|
"log",
|
||||||
"maps",
|
"maps",
|
||||||
"math",
|
"math",
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,8 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build goexperiment.rangefunc
|
|
||||||
|
|
||||||
// Package iter provides basic definitions and operations
|
// Package iter provides basic definitions and operations
|
||||||
// related to iteration in Go.
|
// related to iteration in Go.
|
||||||
//
|
|
||||||
// This package is experimental and can only be imported
|
|
||||||
// when building with GOEXPERIMENT=rangefunc.
|
|
||||||
package iter
|
package iter
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,11 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build goexperiment.rangefunc
|
package iter_test
|
||||||
|
|
||||||
package iter
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
. "iter"
|
||||||
"runtime"
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
@ -33,7 +32,6 @@ func squares(n int) Seq2[int, int64] {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPull(t *testing.T) {
|
func TestPull(t *testing.T) {
|
||||||
|
|
||||||
for end := 0; end <= 3; end++ {
|
for end := 0; end <= 3; end++ {
|
||||||
t.Run(fmt.Sprint(end), func(t *testing.T) {
|
t.Run(fmt.Sprint(end), func(t *testing.T) {
|
||||||
ng := runtime.NumGoroutine()
|
ng := runtime.NumGoroutine()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue