[−][src]Function triple_accel::levenshtein::levenshtein_search
pub fn levenshtein_search<'a>(
needle: &'a [u8],
haystack: &'a [u8]
) -> Box<dyn Iterator<Item = Match> + 'a>
Returns an iterator over best Match
s by searching through the text haystack
for the
pattern needle
using SIMD acceleration.
The best matches are the matches with the lowest Levenshtein distance. Note that overlapping
best matches may be returned.
If multiple best matches end at the same position, then the longest match is chosen.
Internally, this will call levenshtein_search_simd
.
If AVX2 or SSE4.1 is not supported, then this will automatically fall back to a scalar alternative.
Arguments
needle
- pattern string (slice)haystack
- text string (slice)
Example
let matches: Vec<Match> = levenshtein_search(b"abc", b" abd").collect(); // note: it is possible to end the match at two different positions assert!(matches == vec![Match{start: 2, end: 4, k: 1}, Match{start: 2, end: 5, k: 1}]);