Hi all,
When I use the rust-analyzer from emacs (with the eglot lsp client) for a function like a .map
I tend to expect that it will fill in the template for me based on the type of the thing that I'm mapping over. e.g. if I have a HashMap
and I .map
over it, I expect the auto-filled template to give me
.map(|(a, b)| _ )
where I would be asked to enter the a
, b
and finally _
values (tabbing as I finish each, in typical emacs completion style). This is how autocomplete works in other typed languages with lambda functions, such as Scala.
However, in Rust, the template is only ever
.map(f)
which means I need to manually open the |
then the parameter list, then the closing |
. Obviously this is because it's doing exactly what is expected of the verbatim function
fn map<B, F>(self, f: F) -> Map<Self, F>
where
Self: Sized,
F: FnMut(Self::Item) -> B,
{
Map::new(self, f)
}
but wouldn't it be cool if the analyzer was able to detect this (very common!) case and go one step further, expanding out on | Self::Item |
instead of the f: F
. It would already be of great benefit if the opening and closing |
characters were inserted, without looking further into the Item
to see if it is a tuple, as I tend to always expect Emacs to close parents off for me (old habits die hard).
Is there a setting for this that I've overlooked in User Manual or will I just have to wait for it to be implemented? I don't really want to make a feature request because the backlog is already almost 2k issues on github and I'm sure this will just get lost in the noise.