]> Cypherpunks repositories - gostls13.git/commitdiff
slices: update docs for All, Backward, Values
authorJes Cok <xigua67damn@gmail.com>
Thu, 27 Jun 2024 16:00:00 +0000 (00:00 +0800)
committerGopher Robot <gobot@golang.org>
Thu, 27 Jun 2024 17:17:57 +0000 (17:17 +0000)
For #61899

Change-Id: I3586b9b59e87159d21e1a270dabb3af213592739
Reviewed-on: https://go-review.googlesource.com/c/go/+/595515
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
src/slices/iter.go

index 131cece3a06ff4f556bbbcb70a2c1e2a06a1c04d..cd8f308ca08ece84536cd86e6e1e24ff50397062 100644 (file)
@@ -9,8 +9,8 @@ import (
        "iter"
 )
 
-// All returns an iterator over index-value pairs in the slice.
-// The indexes range in the usual order, from 0 through len(s)-1.
+// All returns an iterator over index-value pairs in the slice
+// in the usual order.
 func All[Slice ~[]E, E any](s Slice) iter.Seq2[int, E] {
        return func(yield func(int, E) bool) {
                for i, v := range s {
@@ -22,7 +22,7 @@ func All[Slice ~[]E, E any](s Slice) iter.Seq2[int, E] {
 }
 
 // Backward returns an iterator over index-value pairs in the slice,
-// traversing it backward. The indexes range from len(s)-1 down to 0.
+// traversing it backward with descending indices.
 func Backward[Slice ~[]E, E any](s Slice) iter.Seq2[int, E] {
        return func(yield func(int, E) bool) {
                for i := len(s) - 1; i >= 0; i-- {
@@ -33,8 +33,7 @@ func Backward[Slice ~[]E, E any](s Slice) iter.Seq2[int, E] {
        }
 }
 
-// Values returns an iterator over the slice elements,
-// starting with s[0].
+// Values returns an iterator that yields the slice elements in order.
 func Values[Slice ~[]E, E any](s Slice) iter.Seq[E] {
        return func(yield func(E) bool) {
                for _, v := range s {