1
Fork 0

rustdoc: use restricted Damerau-Levenshtein distance for search

Based on https://github.com/rust-lang/rust/pull/108200, for the same
rationale.

> This replaces the existing Levenshtein algorithm with the
> Damerau-Levenshtein algorithm. This means that "ab" to "ba" is one change
> (a transposition) instead of two (a deletion and insertion). More
> specifically, this is a restricted implementation, in that "ca" to "abc"
> cannot be performed as "ca" → "ac" → "abc", as there is an insertion in the
> middle of a transposition. I believe that errors like that are sufficiently
> rare that it's not worth taking into account.

Before this change, searching `prinltn!` listed `print!` first, followed
by `println!`. With this change, `println!` matches more closely.
This commit is contained in:
Michael Howell 2023-03-10 18:18:43 -07:00
parent ff4b772f80
commit dfd9e5e3fa
2 changed files with 225 additions and 145 deletions

View file

@ -0,0 +1,12 @@
// exact-check
const QUERY = 'prinltn';
const FILTER_CRATE = 'std';
const EXPECTED = {
'others': [
{ 'path': 'std', 'name': 'println' },
{ 'path': 'std', 'name': 'print' },
{ 'path': 'std', 'name': 'eprintln' },
],
};