Skip to content

Commit 5efb423

Browse files
griesemergopherbot
authored andcommitted
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 <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Auto-Submit: Robert Griesemer <[email protected]> TryBot-Bypass: Robert Griesemer <[email protected]>
1 parent 0d8aa8c commit 5efb423

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

doc/go_spec.html

+4
Original file line numberDiff line numberDiff line change
@@ -5686,6 +5686,8 @@ <h4 id="Conversions_to_and_from_a_string_type">Conversions to and from a string
56865686
<li>
56875687
Converting a value of a string type to a slice of bytes type
56885688
yields a non-nil slice whose successive elements are the bytes of the string.
5689+
The <a href="#Length_and_capacity">capacity</a> of the resulting slice is
5690+
implementation-specific and may be larger than the slice length.
56895691

56905692
<pre>
56915693
[]byte("hellø") // []byte{'h', 'e', 'l', 'l', '\xc3', '\xb8'}
@@ -5701,6 +5703,8 @@ <h4 id="Conversions_to_and_from_a_string_type">Conversions to and from a string
57015703
<li>
57025704
Converting a value of a string type to a slice of runes type
57035705
yields a slice containing the individual Unicode code points of the string.
5706+
The <a href="#Length_and_capacity">capacity</a> of the resulting slice is
5707+
implementation-specific and may be larger than the slice length.
57045708

57055709
<pre>
57065710
[]rune(myString("白鵬翔")) // []rune{0x767d, 0x9d6c, 0x7fd4}

0 commit comments

Comments
 (0)