Struct needle::Horspool [] [src]

pub struct Horspool<'a, H: 'a + ?Sized> { /* fields omitted */ }

Methods

impl<'a, H: ?Sized, T> Horspool<'a, H> where
    T: 'a + Copy + PartialEq + Into<usize>,
    H: 'a + Searchable<Item = T>, 
[src]

Finds the first occurence of the search term in haystack and returns the index if it is found.

Returns an iterator that will produce the indices of the needle in the haystack. This iterator will not find overlapping matches; the first character of a match will start after the last character of the previous match.

Example

use needle::Horspool;
let needle = Horspool::new(&b"aaba"[..]);
let haystack = b"aabaabaabaabaaba";
assert_eq!(vec![0,6,12], needle.find_in(haystack).collect::<Vec<usize>>());

Returns an iterator that will produce the indices of the needle in the haystack. This iterator will find overlapping matches; the first character of a match is allowed to be matched from within the previous match.

Example

use needle::Horspool;
let needle = Horspool::new(&b"aaba"[..]);
let haystack = b"aabaabaabaabaaba";
assert_eq!(vec![0,3,6,9,12], needle.find_overlapping_in(haystack).collect::<Vec<usize>>());