Function
find_ocurrences
(text: String, first: String, second: String)
Source from the content-addressed store, hash-verified
| 1 | pub fn find_ocurrences(text: String, first: String, second: String) -> Vec<String> { |
| 2 | let strs: Vec<String> = text.split(" ").map(|s|s.to_string()).collect(); |
| 3 | let tail_index = &strs.len() - 2; |
| 4 | let mut res: Vec<String> = Vec::new(); |
| 5 | for i in 0..tail_index { |
| 6 | if strs[i] == first && strs[i+1] == second { |
| 7 | res.push(strs[i+2].clone()); |
| 8 | } |
| 9 | } |
| 10 | res |
| 11 | } |
| 12 | |
| 13 | fn main() { |
| 14 | let text = "we will we will rock you".to_string(); |
Callers
nothing calls this directly
Tested by
no test coverage detected