Skip to content

Commit

Permalink
slices: clarify Insert behavior if i == len(s)
Browse files Browse the repository at this point in the history
Fixes #69104

Change-Id: Ie928239d5ef198ce36759ec4cffb7f6320ff3b82
Reviewed-on: https://go-review.googlesource.com/c/go/+/609175
Reviewed-by: Eli Bendersky <eliben@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
  • Loading branch information
ianlancetaylor authored and gopherbot committed Aug 28, 2024
1 parent fe63d48 commit 6d52d7d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/slices/slices.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6d52d7d

Please sign in to comment.