From: Ian Lance Taylor Date: Wed, 28 Aug 2024 16:33:49 +0000 (-0700) Subject: slices: clarify Insert behavior if i == len(s) X-Git-Tag: go1.24rc1~1092 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=6d52d7d22b70a5faa2868b6406ccdc7fd9b89083;p=gostls13.git slices: clarify Insert behavior if i == len(s) Fixes #69104 Change-Id: Ie928239d5ef198ce36759ec4cffb7f6320ff3b82 Reviewed-on: https://go-review.googlesource.com/c/go/+/609175 Reviewed-by: Eli Bendersky Reviewed-by: Ian Lance Taylor Auto-Submit: Ian Lance Taylor LUCI-TryBot-Result: Go LUCI Commit-Queue: Ian Lance Taylor --- diff --git a/src/slices/slices.go b/src/slices/slices.go index 200e653dde..b53419f84b 100644 --- a/src/slices/slices.go +++ b/src/slices/slices.go @@ -128,8 +128,8 @@ func ContainsFunc[S ~[]E, E any](s S, f func(E) bool) bool { // returning the modified slice. // The elements at s[i:] are shifted up to make room. // In the returned slice r, r[i] == v[0], -// and r[i+len(v)] == value originally at r[i]. -// Insert panics if i is out of range. +// and, if i < len(s), r[i+len(v)] == value originally at r[i]. +// Insert panics if i > len(s). // This function is O(len(s) + len(v)). func Insert[S ~[]E, E any](s S, i int, v ...E) S { _ = s[i:] // bounds check