spec: document that string conversions don't guarantee result slice capacity

Fixes #24163.

Change-Id: If389c4abf3b9b6e4eba6f31c3c12779329456df6
Reviewed-on: https://go-review.googlesource.com/c/go/+/637655
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Bypass: Robert Griesemer <gri@google.com>
This commit is contained in:
Robert Griesemer 2024-12-18 14:15:48 -08:00 committed by Gopher Robot
parent 0d8aa8cce6
commit 5efb4239c6

View file

@ -5686,6 +5686,8 @@ myString([]myRune{0x1f30e}) // "\U0001f30e" == "🌎"
<li> <li>
Converting a value of a string type to a slice of bytes type Converting a value of a string type to a slice of bytes type
yields a non-nil slice whose successive elements are the bytes of the string. yields a non-nil slice whose successive elements are the bytes of the string.
The <a href="#Length_and_capacity">capacity</a> of the resulting slice is
implementation-specific and may be larger than the slice length.
<pre> <pre>
[]byte("hellø") // []byte{'h', 'e', 'l', 'l', '\xc3', '\xb8'} []byte("hellø") // []byte{'h', 'e', 'l', 'l', '\xc3', '\xb8'}
@ -5701,6 +5703,8 @@ bytes("hellø") // []byte{'h', 'e', 'l', 'l', '\xc3', '\xb8'}
<li> <li>
Converting a value of a string type to a slice of runes type Converting a value of a string type to a slice of runes type
yields a slice containing the individual Unicode code points of the string. yields a slice containing the individual Unicode code points of the string.
The <a href="#Length_and_capacity">capacity</a> of the resulting slice is
implementation-specific and may be larger than the slice length.
<pre> <pre>
[]rune(myString("白鵬翔")) // []rune{0x767d, 0x9d6c, 0x7fd4} []rune(myString("白鵬翔")) // []rune{0x767d, 0x9d6c, 0x7fd4}