bytes, strings: document that FieldsFunc f must not be stateful

Fixes #8738.

LGTM=adg
R=golang-codereviews, adg
CC=golang-codereviews
https://golang.org/cl/143260045
This commit is contained in:
Russ Cox 2014-09-18 19:40:31 -04:00
parent ab76638cdc
commit e9ec8e7a26
2 changed files with 4 additions and 0 deletions

View file

@ -347,6 +347,8 @@ func Fields(s string) []string {
// FieldsFunc splits the string s at each run of Unicode code points c satisfying f(c)
// and returns an array of slices of s. If all code points in s satisfy f(c) or the
// string is empty, an empty slice is returned.
// FieldsFunc makes no guarantees about the order in which it calls f(c).
// If f does not return consistent results for a given c, FieldsFunc may crash.
func FieldsFunc(s string, f func(rune) bool) []string {
// First count the fields.
n := 0