Commit 1a4402a1 authored by Andrew Gerrand's avatar Andrew Gerrand

bytes: add Contains function

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5349041
parent 632a2c59
......@@ -88,6 +88,11 @@ func Count(s, sep []byte) int {
return n
}
// Contains returns whether subslice is within b.
func Contains(b, subslice []string) bool {
return Index(b, subslice) != -1
}
// Index returns the index of the first instance of sep in s, or -1 if sep is not present in s.
func Index(s, sep []byte) int {
n := len(sep)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment