Function naive_opt::string_search_indices [−][src]
pub fn string_search_indices<'a, 'b>(
haystack: &'a str,
needle: &'b str
) -> SearchIndices2<'a, 'b>ⓘNotable traits for SearchIndices2<'a, 'b>
impl<'a, 'b> Iterator for SearchIndices2<'a, 'b> type Item = (usize, &'a str);
An iterator over the matches of the needle in the haystack.
Examples
use naive_opt::string_search_indices; let v: Vec<_> = string_search_indices("abc345abc901abc", "abc").collect(); assert_eq!(v, [(0, "abc"), (6, "abc"), (12, "abc")]); let v: Vec<_> = string_search_indices("0abcabc7", "abc").collect(); assert_eq!(v, [(1, "abc"), (4, "abc")]); let v: Vec<_> = string_search_indices("ababa", "aba").collect(); assert_eq!(v, [(0, "aba")]); // only the first `aba`