Skip to content

Commit 95a3779

Browse files
qiulaidongfenggopherbot
authored andcommitted
reflect: clarify documentation for Value.Seq/Seq2
For #66056 Change-Id: Ib47c07b2527d8213584b72e2575a353f2deaed68 GitHub-Last-Rev: 525a5c3 GitHub-Pull-Request: #67268 Reviewed-on: https://go-review.googlesource.com/c/go/+/584515 Reviewed-by: Cherry Mui <[email protected]> Commit-Queue: Ian Lance Taylor <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 9eebdca commit 95a3779

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/reflect/iter.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ package reflect
66

77
import "iter"
88

9-
// Seq returns an iter.Seq[reflect.Value] that loops over the elements of v.
9+
// Seq returns an iter.Seq[Value] that loops over the elements of v.
1010
// If v's kind is Func, it must be a function that has no results and
1111
// that takes a single argument of type func(T) bool for some type T.
1212
// If v's kind is Pointer, the pointer element type must have kind Array.
@@ -87,7 +87,11 @@ func (v Value) Seq() iter.Seq[Value] {
8787
panic("reflect: " + v.Type().String() + " cannot produce iter.Seq[Value]")
8888
}
8989

90-
// Seq2 is like Seq but for two values.
90+
// Seq2 returns an iter.Seq2[Value, Value] that loops over the elements of v.
91+
// If v's kind is Func, it must be a function that has no results and
92+
// that takes a single argument of type func(K, V) bool for some type K, V.
93+
// If v's kind is Pointer, the pointer element type must have kind Array.
94+
// Otherwise v's kind must be Array, Map, Slice, or String.
9195
func (v Value) Seq2() iter.Seq2[Value, Value] {
9296
if canRangeFunc2(v.typ()) {
9397
return func(yield func(Value, Value) bool) {

0 commit comments

Comments
 (0)