[][src]Trait kmpsearch::Haystack

pub trait Haystack {
    fn contains_needle<N: AsRef<[u8]>>(&self, needle: N) -> bool;

    fn pattern_table(needle: &[u8]) -> Vec<usize> { ... }
}

The Haystack trait is the 'target' of the KMP algorithm provided by this library. It provides the pattern_table method (part of the KMP algorithm) and the contains_needle method. Haystack is implemented on all types that can be converted to a &u8, such as Byte slices, str and Strings.

Required methods

fn contains_needle<N: AsRef<[u8]>>(&self, needle: N) -> bool

Returns true if this Haystack contains needle.

Loading content...

Provided methods

fn pattern_table(needle: &[u8]) -> Vec<usize>

Produce a 'pattern table' for use with the Knuth Morris Pratt algorithm

Loading content...

Implementors

impl<H: AsRef<[u8]>> Haystack for H[src]

fn pattern_table(needle: &[u8]) -> Vec<usize>[src]

Loading content...