]> Cypherpunks repositories - gostls13.git/commitdiff
slices: document that Clone can return extra capacity
authorIan Lance Taylor <iant@golang.org>
Sun, 3 Mar 2024 02:48:26 +0000 (18:48 -0800)
committerGopher Robot <gobot@golang.org>
Tue, 5 Mar 2024 20:52:30 +0000 (20:52 +0000)
Change-Id: I8b9aa1f36ce554d8855ee70e15f0dd0a8cf1097a
Reviewed-on: https://go-review.googlesource.com/c/go/+/568342
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>

src/slices/slices.go

index 49a76dac7a58293e01497c4743f214f5bc91f8bd..326584064c0c1c9db419fa89a564cd92af521a45 100644 (file)
@@ -342,6 +342,7 @@ func Replace[S ~[]E, E any](s S, i, j int, v ...E) S {
 
 // Clone returns a copy of the slice.
 // The elements are copied using assignment, so this is a shallow clone.
+// The result may have additional unused capacity.
 func Clone[S ~[]E, E any](s S) S {
        // The s[:0:0] preserves nil in case it matters.
        return append(s[:0:0], s...)