Trait naive_opt::Search [−][src]
search the needle
Required methods
fn search<'a, P: SearchIn<'a>>(&'a self, needle: P) -> Option<usize>
[src]
search the needle in self.
return index of self, if it found the needle. Otherwise return None.
fn search_indices<'a, P: SearchIn<'a>>(
&'a self,
needle: P
) -> SearchIndices<'a, P>ⓘNotable traits for SearchIndices<'a, P>
impl<'a, P: SearchIn<'a>> Iterator for SearchIndices<'a, P> type Item = (usize, &'a str);
[src]
&'a self,
needle: P
) -> SearchIndices<'a, P>ⓘ
Notable traits for SearchIndices<'a, P>
impl<'a, P: SearchIn<'a>> Iterator for SearchIndices<'a, P> type Item = (usize, &'a str);
An iterator over the matches of needle in self.
Examples
use naive_opt::Search; let v: Vec<_> = "abc345abc901abc".search_indices("abc").collect(); assert_eq!(v, [(0, "abc"), (6, "abc"), (12, "abc")]); let v: Vec<_> = "0abcabc7".search_indices("abc").collect(); assert_eq!(v, [(1, "abc"), (4, "abc")]); let v: Vec<_> = "ababa".search_indices("aba").collect(); assert_eq!(v, [(0, "aba")]); // only the first `aba`
Implementations on Foreign Types
impl<'c> Search for &'c str
[src]
fn search<'a, P: SearchIn<'a>>(&'a self, needle: P) -> Option<usize>
[src]
fn search_indices<'a, P: SearchIn<'a>>(
&'a self,
needle: P
) -> SearchIndices<'a, P>ⓘNotable traits for SearchIndices<'a, P>
impl<'a, P: SearchIn<'a>> Iterator for SearchIndices<'a, P> type Item = (usize, &'a str);
[src]
&'a self,
needle: P
) -> SearchIndices<'a, P>ⓘ
Notable traits for SearchIndices<'a, P>
impl<'a, P: SearchIn<'a>> Iterator for SearchIndices<'a, P> type Item = (usize, &'a str);
impl<'c> Search for String
[src]
fn search<'a, P: SearchIn<'a>>(&'a self, needle: P) -> Option<usize>
[src]
fn search_indices<'a, P: SearchIn<'a>>(
&'a self,
needle: P
) -> SearchIndices<'a, P>ⓘNotable traits for SearchIndices<'a, P>
impl<'a, P: SearchIn<'a>> Iterator for SearchIndices<'a, P> type Item = (usize, &'a str);
[src]
&'a self,
needle: P
) -> SearchIndices<'a, P>ⓘ
Notable traits for SearchIndices<'a, P>
impl<'a, P: SearchIn<'a>> Iterator for SearchIndices<'a, P> type Item = (usize, &'a str);