Change-Id: I340e892aa4ecc780905be984016efc86699a45a2
Reviewed-on: https://go-review.googlesource.com/c/go/+/533556
Run-TryBot: shuang cui <imcusg@gmail.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
// false
}
+func ExampleContainsFunc() {
+ f := func(r rune) bool {
+ return r >= 'a' && r <= 'z'
+ }
+ fmt.Println(bytes.ContainsFunc([]byte("HELLO"), f))
+ fmt.Println(bytes.ContainsFunc([]byte("World"), f))
+ // Output:
+ // false
+ // true
+}
+
func ExampleCount() {
fmt.Println(bytes.Count([]byte("cheese"), []byte("e")))
fmt.Println(bytes.Count([]byte("five"), []byte(""))) // before & after each rune
// false
}
+func ExampleContainsFunc() {
+ f := func(r rune) bool {
+ return r == 'a' || r == 'e' || r == 'i' || r == 'o' || r == 'u'
+ }
+ fmt.Println(strings.ContainsFunc("hello", f))
+ fmt.Println(strings.ContainsFunc("rhythms", f))
+ // Output:
+ // true
+ // false
+}
+
func ExampleCount() {
fmt.Println(strings.Count("cheese", "e"))
fmt.Println(strings.Count("five", "")) // before & after each rune