Trait naive_opt::Search[][src]

pub trait Search {
    fn search<'a, P: SearchIn<'a>>(&'a self, needle: P) -> Option<usize>;
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);
; }

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]

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`
Loading content...

Implementations on Foreign Types

impl<'c> Search for &'c str[src]

impl<'c> Search for String[src]

Loading content...

Implementors

Loading content...