]> Cypherpunks repositories - gostls13.git/commitdiff
iter: expose fundamental types to Go 1.23
authorRuss Cox <rsc@golang.org>
Tue, 23 Jan 2024 17:01:53 +0000 (12:01 -0500)
committerRuss Cox <rsc@golang.org>
Mon, 6 May 2024 20:33:25 +0000 (20:33 +0000)
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>
api/next/61897.txt [new file with mode: 0644]
doc/next/6-stdlib/3-iter.md [new file with mode: 0644]
doc/next/6-stdlib/99-minor/iter/61897.md [new file with mode: 0644]
src/go/build/deps_test.go
src/go/doc/comment/std.go
src/iter/iter.go
src/iter/pull_test.go

diff --git a/api/next/61897.txt b/api/next/61897.txt
new file mode 100644 (file)
index 0000000..9f5a2d9
--- /dev/null
@@ -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
diff --git a/doc/next/6-stdlib/3-iter.md b/doc/next/6-stdlib/3-iter.md
new file mode 100644 (file)
index 0000000..15ae7d4
--- /dev/null
@@ -0,0 +1,4 @@
+### Iterators
+
+The new [`iter` package](/pkg/iter/) provides the basic definitions for
+working with user-defined iterators.
diff --git a/doc/next/6-stdlib/99-minor/iter/61897.md b/doc/next/6-stdlib/99-minor/iter/61897.md
new file mode 100644 (file)
index 0000000..02d77cd
--- /dev/null
@@ -0,0 +1 @@
+<!-- see ../../3-iter.md -->
index 14880d9ef120216fcc302cdab923e6bc9ab89257..3b8434fef4076b427f65f5adf9e9760848aec1b3 100644 (file)
@@ -85,11 +85,9 @@ var depsRules = `
        < internal/reflectlite
        < errors
        < internal/oserror, math/bits
+       < iter
        < RUNTIME;
 
-       internal/race
-       < iter;
-
        # slices depends on unsafe for overlapping check, cmp for comparison
        # semantics, and math/bits for # calculating bitlength of numbers.
        unsafe, cmp, math/bits
@@ -389,7 +387,6 @@ var depsRules = `
        internal/nettrace,
        internal/poll,
        internal/singleflight,
-       internal/race,
        net/netip,
        os
        < net;
index e19792c825ba3093feb30463c19dc22d15fe860e..35caa8b3191cead47803b980b5f9513b06d5b2ed 100644 (file)
@@ -23,6 +23,7 @@ var stdPkgs = []string{
        "html",
        "image",
        "io",
+       "iter",
        "log",
        "maps",
        "math",
index 40e47703479347aa32af2ce6d2a8b768f6581ded..4d9cfad73bb7ce499cc212e860652bb9c7ff0db5 100644 (file)
@@ -2,13 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build goexperiment.rangefunc
-
 // Package iter provides basic definitions and operations
 // related to iteration in Go.
-//
-// This package is experimental and can only be imported
-// when building with GOEXPERIMENT=rangefunc.
 package iter
 
 import (
index 38e0ee993a190490a7167e41f742e06d52b05698..4a9510a8045f5ab791c21236d0a0c2bf90ca345b 100644 (file)
@@ -2,12 +2,11 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build goexperiment.rangefunc
-
-package iter
+package iter_test
 
 import (
        "fmt"
+       . "iter"
        "runtime"
        "testing"
 )
@@ -33,7 +32,6 @@ func squares(n int) Seq2[int, int64] {
 }
 
 func TestPull(t *testing.T) {
-
        for end := 0; end <= 3; end++ {
                t.Run(fmt.Sprint(end), func(t *testing.T) {
                        ng := runtime.NumGoroutine()