aboutsummaryrefslogtreecommitdiff
path: root/src/bytes/example_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/bytes/example_test.go')
-rw-r--r--src/bytes/example_test.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/bytes/example_test.go b/src/bytes/example_test.go
index 20faf3e1f5..5a66b1e436 100644
--- a/src/bytes/example_test.go
+++ b/src/bytes/example_test.go
@@ -212,6 +212,17 @@ func ExampleContainsRune() {
// 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