From 9e3b1d53a012e98cfd02de2de8b1bd53522464d4 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Sat, 2 Mar 2024 18:48:26 -0800 Subject: [PATCH] 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 LUCI-TryBot-Result: Go LUCI Reviewed-by: Keith Randall Reviewed-by: Keith Randall Auto-Submit: Ian Lance Taylor --- src/slices/slices.go | 1 + 1 file changed, 1 insertion(+) diff --git a/src/slices/slices.go b/src/slices/slices.go index 49a76dac7a..326584064c 100644 --- a/src/slices/slices.go +++ b/src/slices/slices.go @@ -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...) -- 2.48.1