Skip to content

Commit 9e3b1d5

Browse files
ianlancetaylorgopherbot
authored andcommitted
slices: document that Clone can return extra capacity
Change-Id: I8b9aa1f36ce554d8855ee70e15f0dd0a8cf1097a Reviewed-on: https://go-review.googlesource.com/c/go/+/568342 Reviewed-by: Michael Knyszek <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Keith Randall <[email protected]> Reviewed-by: Keith Randall <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]>
1 parent 16e5d24 commit 9e3b1d5

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/slices/slices.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ func Replace[S ~[]E, E any](s S, i, j int, v ...E) S {
342342

343343
// Clone returns a copy of the slice.
344344
// The elements are copied using assignment, so this is a shallow clone.
345+
// The result may have additional unused capacity.
345346
func Clone[S ~[]E, E any](s S) S {
346347
// The s[:0:0] preserves nil in case it matters.
347348
return append(s[:0:0], s...)

0 commit comments

Comments
 (0)