-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support finding permutations of -_
in crate names
#75
Comments
The naive algorithm is exponential. It's not a good solution to query names like that. It's better to list all crates and make an index with So overall I don't think solution to this problem belongs to this crate. |
The indexed lookup is much faster yes, but there are a lot of one-off utilities like Benchmarking using the algorithm I think having this algorithm in one centralized crate is much better than every cargo subcommand copy-pasting it again and again. |
I think it would be feasible to add a new method that has the fuzzy lookup behaviour, and contributions for this would be very welcome. |
What about… adding a permutation iterator? Given a name, it will permute through the possible settings of crate_index::Names::new("the-crate-I-look-for").find(|name| index.crate_(name)) This keeps the implementation primitive, which helps when thinking about future abstractions as well. |
It would be useful for tools that want to emulate crates.io's behavior around fuzzy matching of
-
and_
in crate names if there would be an api likeIndex::crate_
that would also search for the different permutations if there was no exact match.For example in
cargo-edit
: https://github.com/killercup/cargo-edit/blob/c3bb5e5cc089556e4bac2f9b370c4ca0dccb1de6/src/fetch.rs#L123-L160The text was updated successfully, but these errors were encountered: