Function triple_accel::hamming::hamming_search_naive_with_opts[][src]

pub fn hamming_search_naive_with_opts<'a>(
    needle: &'a [u8],
    haystack: &'a [u8],
    k: u32,
    search_type: SearchType
) -> Box<dyn Iterator<Item = Match> + 'a>
Expand description

Returns an iterator over Matchs by naively searching through the text haystack for the pattern needle, with extra options.

Only matches with less than k mismatches are returned. This is done by naively counting mismatches at every position in haystack. The length of needle must be less than or equal to the length of haystack.

Arguments

  • needle - pattern string (slice)
  • haystack - text string (slice)
  • k - number of mismatches allowed
  • search_type - whether to only return the “best” matches with the lowest Hamming distance, or all matches

Example

let matches: Vec<Match> = hamming_search_naive_with_opts(b"abc", b"  abd", 1, SearchType::All).collect();

assert!(matches == vec![Match{start: 2, end: 5, k: 1}]);