feat: provide suggestions if a function cannot be found#524
Conversation
Wodann
left a comment
There was a problem hiding this comment.
Looks awesome! Just one nitpick
Codecov Report
@@ Coverage Diff @@
## main #524 +/- ##
==========================================
+ Coverage 87.05% 87.15% +0.10%
==========================================
Files 274 275 +1
Lines 31028 31082 +54
==========================================
+ Hits 27011 27090 +79
+ Misses 4017 3992 -25
|
Wodann
left a comment
There was a problem hiding this comment.
LGTM! I'll let @baszalmstra have a look too before merging
sounds good thanks! |
baszalmstra
left a comment
There was a problem hiding this comment.
Looks good to me! I left some small comments.
| } | ||
|
|
||
| /// Retrieves the name of all available functions. | ||
| pub fn get_fn_names(&self) -> Vec<&str> { |
There was a problem hiding this comment.
You can also return an iterator to avoid allocating memory for the vec
Just pushed the changes! |
If a function is not found, a suggestion is added to the error message if a close match exists.
To measure if there is a close match, the difference between the names are measured using Levenshtein distance, the approach is based on here: https://github.com/rust-lang/rust/blob/488acf86a75c56d30b16822e953c505a9e4901a7/compiler/rustc_span/src/lev_distance.rs#L46-L48
Fixes: #412