Counting occurrences of a substring in a string

Regarding overlaps it should works akin to the following method of standard library and its answer will be 2.

func components(separatedBy separator: String) -> [String]

I think it will be a great idea to generalise this pitch to Sequence.