pub fn find(&self, candidate: &str) -> Option<Match> {
        let cand_chars: Vec<char> = candidate.chars().map(|c| c.to_ascii_lowercase()).collect();
        if cand_chars.len() < self.lc_chars.len() {
            return None;
        }
        let mut best_score = 0;
        let mut best_match: Option<Match> = None;
        for start_idx in 0..=cand_chars.len() - self.lc_chars.len() {
            let sm = self.match_starting_at_index(&cand_chars, start_idx);
            if let Some(m) = sm {
                if m.score > best_score {
                    best_score = m.score;
                    best_match = Some(m);
                }
            }
        }
        best_match
    }
// return a match if the pattern can be found in the candidate string.
// The algorithm tries to return the best one. For example if you search
// "abc" in "ababaca-abc", the returned match would be at the end.
return a match if the pattern can be found in the candidate string.
The algorithm tries to return the best one. For example if you search
"abc" in "ababaca-abc", the returned match would be at the end.
return a match if the pattern can be found in the candidate string . The algorithm tries to return the best one . For example if you search " abc " in " ababaca - abc " the returned match would be at the end .
pub fn find(&self, candidate: &str) -> Option<Match> {
        let cand_chars: Vec<char> = candidate.chars().map(|c| c.to_ascii_lowercase()).collect();
        if cand_chars.len() < self.lc_chars.len() {
            return None;
        }
        let mut best_score = 0;
        let mut best_match: Option<Match> = None;
        for start_idx in 0..=cand_chars.len() - self.lc_chars.len() {
            let sm = self.match_starting_at_index(&cand_chars, start_idx);
            if let Some(m) = sm {
                if m.score > best_score {
                    best_score = m.score;
                    best_match = Some(m);
                }
            }
        }
        best_match
    }
pub fn find ( & self , candidate : & str ) -> Option < Match > { let cand_chars : Vec < char > = candidate . chars ( ) . map ( | c | c . to_ascii_lowercase ( ) ) . collect ( ) ; if cand_chars . len ( ) < self . lc_chars . len ( ) { return None ; } let mut best_score = 0 ; let mut best_match : Option < Match > = None ; for start_idx in 0 ..= cand_chars . len ( ) - self . lc_chars . len ( ) { let sm = self . match_starting_at_index ( & cand_chars , start_idx ) ; if let Some ( m ) = sm { if m . score > best_score { best_score = m . score ; best_match = Some ( m ) ; } } } best_match }
return a match if the pattern can be found in the candidate string.
return a match if the pattern can be found in the candidate string .
&self
candidate
&str
&self
candidate
&str