pub fn new(pattern: &'a [u8]) -> Self {
        let mut fail = Vec::with_capacity(pattern.len());
        fail.push(0);
        let mut len = 0;
        for &ch in &pattern[1..] {
            while len > 0 && pattern[len] != ch {
                len = fail[len - 1];
            }
            if pattern[len] == ch {
                len += 1;
            }
            fail.push(len);
        }
        Self { pattern, fail }
    }
/// Precomputes the automaton that allows linear-time string matching.
///
/// # Panics
///
/// Panics if pattern is empty.
Precomputes the automaton that allows linear-time string matching.
Precomputes the automaton that allows linear - time string matching .
pub fn new(pattern: &'a [u8]) -> Self {
        let mut fail = Vec::with_capacity(pattern.len());
        fail.push(0);
        let mut len = 0;
        for &ch in &pattern[1..] {
            while len > 0 && pattern[len] != ch {
                len = fail[len - 1];
            }
            if pattern[len] == ch {
                len += 1;
            }
            fail.push(len);
        }
        Self { pattern, fail }
    }
pub fn new ( pattern : & ' a [ u8 ] ) -> Self { let mut fail = Vec :: with_capacity ( pattern . len ( ) ) ; fail . push ( 0 ) ; let mut len = 0 ; for & ch in & pattern [ 1 .. ] { while len > 0 && pattern [ len ] != ch { len = fail [ len - 1 ] ; } if pattern [ len ] == ch { len += 1 ; } fail . push ( len ) ; } Self { pattern , fail } }
Precomputes the automaton that allows linear-time string matching.
Precomputes the automaton that allows linear - time string matching .
pattern
&'a [u8]
pattern
&'a [u8]
panics
Panics if pattern is empty.
Panics if pattern is empty .