Skip to content

Show _ type #19871

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

Open
latot opened this issue May 26, 2025 · 5 comments
Open

Show _ type #19871

latot opened this issue May 26, 2025 · 5 comments
Labels
C-feature Category: feature request

Comments

@latot
Copy link

latot commented May 26, 2025

Hi! I think would be nice be able to see in the IDEs which type currently have the use of "", while some times is needed, I think some time is not always to guess what "" will be, for example on multiple map operations, we can use "_" because we know is implicit, but does not means also know well which is the type, specially if we change it in a prototype.

Also show this would helps readability!

@latot latot added the C-feature Category: feature request label May 26, 2025
@lnicola
Copy link
Member

lnicola commented May 26, 2025

Not sure I understand, do you have an example?

@latot
Copy link
Author

latot commented May 26, 2025

A simpler one:

let a: usize = vec![1, 2, 3];

// Ideally here, to show after the "_" the signature like "_ (usize)" or something like that
let b: Vec<_> = a
.into_iter()
.map(|x| x*x)
.collect()

@ChayimFriedman2
Copy link
Contributor

I think it'll be best if when hovering over a selection of type we'll show the real type, but unfortunately I'm not sure how to implement this, as we have no way to map between the TypeRefId to its inferred type.

@latot
Copy link
Author

latot commented May 26, 2025

D: no way!

I personally, like the idea of see the code and see everything that we need, specially if there is several _, some code have a lot of them, hovering would works better on code that do not use much _.

@ThomasCartier
Copy link

@latot for this specific need:

let b= a.into_iter().map(|x| x * x).collect::<Vec<_>>();

VScode will show the correct type for b.

Not sure if this helps, and pretty sure you knew it already, but there it is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature Category: feature request
Projects
None yet
Development

No branches or pull requests

4 participants