pub fn new(pattern: &'a [T]) -> 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.
///
/// # Example
///
/// ```
/// use contest_algorithms::string_proc::Matcher;
/// let utf8_string = "hello";
///
/// let match_from_byte_literal = Matcher::new(b"hello");
///
/// let match_from_bytes = Matcher::new(utf8_string.as_bytes());
///
/// let vec_char: Vec<char> = utf8_string.chars().collect();
/// let match_from_chars = Matcher::new(&vec_char);
///
/// let vec_int = vec![4, -3, 1];
/// let match_from_ints = Matcher::new(&vec_int);
/// ```
///
/// # 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 [T]) -> 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 [ T ] ) -> 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 [T]
example
```
use contest_algorithms::string_proc::Matcher;
let utf8_string = "hello".

let match_from_byte_literal = Matcher::new(b"hello").

let match_from_bytes = Matcher::new(utf8_string.as_bytes()).

let vec_char: Vec = utf8_string.chars().collect();
let match_from_chars = Matcher::new(&vec_char).


` ` ` use contest_algorithms :: string_proc :: Matcher ; let utf8_string = " hello " . let match_from_byte_literal = Matcher :: new ( b " hello " ) . let match_from_bytes = Matcher :: new ( utf8_string . as_bytes () ) . let vec_char : Vec = utf8_string . chars () . collect () ; let match_from_chars = Matcher :: new ( &vec_char ) .
panics
Panics if pattern is empty.
Panics if pattern is empty .