I recently added rust-analyzer to my vim and realized how cool it is. In particular I like to see the type annotations that it adds when chaining methods, which turns out to be useful for example when using stuff from the Iterator
trait:
let things: Vec<_> = (0..100) Range<i32>
.map(|x| x.to_string()) impl Iterator<Item = String>
.filter(|x| x.len() == 1) impl Iterator<Item = String>
.map(|x| x.chars().next().unwrap()) impl Iterator<Item = char>
.take(3) impl Iterator<Item = char>
.collect();
(I had to paste the code instead of sharing a screenshot because as a new user I can only post one media item , but look at the type annotations on the right)
I wrote a crate (csvsc) that mimics this chaining behavior, using different structs to accomplish different tasks but implemented as a trait (RowStream
) with a lot of methods, just like Iterator
. But when I look at the type annotations that rust-analyzer gives me it has all the type parameters so after a few chained methods they don't even fit the screen:
So the question is, do ye know how can I get that nice impl RowStream
type annotation? Is there a magic trick?