How to quickly navigate to the implementation of a trait method?

Hi, i am using vscode with rust-analyser plugin, i found it takes too much time for me to navigate to the implementation of a trait method.
For example, i have a struct A, which implements Into trait in one of my source file. Now, i am using the struct in another file, and i want to use the method into of Into trait, i don't know the detail type of into method from the vscode comment tips, so i navigate to the into method, but it just navigate to the definition of Into trait. What i can do is that navigating to the definition of A struct first, and then right click A struct, then, click the implenentations tips, and find the Into implementation in a lot of implementations. It annoys me much, and wastes too much time. Is there a good way to quickly navigate to the method where it is defined? please tell me, thanks!

I found

https://github.com/rust-lang/rust-analyzer/issues/4558

based on which I’d say there isn’t a good way yet, but it seems like a feature we’ll get… eventually…


In the particular example of Into::into, note however that that method is most commonly implemented via this single blanket implementation based on From, the definition of which won’t help you much either, I suppose.

If the goal is merely to get a better picture of the type signature of the trait method implementation for the concrete use-case, I suppose some of the limitations discussed in the issue mentioned above don’t apply, so that kind of feature might be easier to pull off than jumping to the definition.


As an alternative (but not necessarily quicker) approach for finding out more about trait implementations of a struct, it’s also often useful to just look into the generated rustdoc. Even for private/internal API, by turning on flags such as --document-private-items, generated rustdoc can be really quite useful.

1 Like

@steffahn Thanks, this is exactly what i mean, but it seems that there is no good way for navigating to implemetation except for using idea for now. :smiling_face_with_tear:

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.