fix string.count

pull/1449/head
Alvydas Vitkauskas 2019-08-03 01:18:19 +03:00 committed by Alexander Medvednikov
parent d4c07d9b66
commit bfdce806c4
1 changed files with 3 additions and 2 deletions

View File

@ -460,13 +460,14 @@ pub fn (s string) count(substr string) int {
return 0
}
mut n := 0
mut i := 0
for {
i := s.index(substr)
i := s.index_after(substr, i)
if i == -1 {
return n
}
i += substr.len
n++
s = s.right(i+substr.len)
}
}