Sometimes _ refers to an inferred type and sometimes it doesn’t. You can’t meaningfully search for '_' or 'underscore' in the reference to find out the rules. Anyway, such rules are a burden and learning obstacle. If there’s a concept, like “_ refers to the inferred type,” it should hold everywhere!
Types can often be rather lengthy, especially generic ones. In constructor type functions (which don’t return Self, e.g. typestate transitions,) as the last thing, one typically repeats the type verbosely. As a legacy of C++, which chose an operator as a bracket, don’t forget to turbofish it, no plain copy & paste! To avoid all that I wanted to infer it, but the compiler didn’t even understand. (The first variant might be unlikely to be used much, it’s just for completeness.)
This should be logically unambiguous, and syntactically as well. The only other thing (???) that can currently have an underscore at the beginning of a statement is
_ = must_use_value();
So I suggest in all contexts where the expected type is clear, to generalise _ to be that type. Looking forward to a Rust that feels even more consistent.
Ah, ok, “like a function” and “the constructor function is not exactly a fn item, there are subtle differences (e.g. with regards to privacy checks), but it’s a close approximation.”
Anyway, named tuples are a bit of a mess. Nice for quick hacks, but at 3 members, the addressing starts to get hairy. Named fields usually win big time for maintainability. So leaving them out of this is fine with me.
Rust analyzer should have a function to help turn them into a normal struct!
I find no such thing. What is a code action? There is the command palette, where I can search a ton of things. This includes super useful RA stuff, like showing a macro expansion. But neither your conversion, nor "code action".
Hmm, on Linux with Ctrl-. I get that menu without the first two lines.
And not sure what you mean about /. If I type that in the code, it of course inserts itself, and in that menu it does nothing. Ctrl-/ comments the line and Alt-/ does nothing.
Command palette finds Source actions (which says there are none available on the S) and CodeLens for current line (which does nothing.)